Printing: Easier in windows?

Hi all.
After trying to print plain text from java for a week, i've realized that this is a far more difficult task than it sounds (if anyone has a magic text printing class, please mail it to me! [email protected]).
But my program only needs to run on win platforms, does that make the problem easier to solve? Are there any win-only classes or native stuff i can use?
Any help appreciated!
Anders.

Hi here it is
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
public class Print extends Frame implements ActionListener, Printable {
TextArea textArea;
public Print() {
pack();
setSize( new Dimension(300,300));
addWindowListener( new CloseWindow());
textArea = new TextArea(" Here you can typ text you want to print out ");
add( textArea, BorderLayout.CENTER);
Button button = new Button ("print");
button.addActionListener (this);
add(button, BorderLayout.SOUTH);
show();
public void actionPerformed(ActionEvent e ) {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
try {
printJob.print();
catch( Exception PrintException) {
public int print( Graphics g, PageFormat f, int n) throws PrinterException {
if ( n >= 1) {
return Printable.NO_SUCH_PAGE;
g.translate(100,100);
g.drawString ((String)textArea.getText(), 0, 0);
paint(g);
return Printable.PAGE_EXISTS;
public static void main(String s[]) {
new Print();
class CloseWindow extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
Hope it helps

Similar Messages

  • Photo Printing from Networked Windows 7

    My HP Photosmart Printer is  USB connected to a Windows XP machine which is directly attached to the home network.  Also have a Windows 7 64 machine  wirelessly connected to the home network.  The Photosmart printer was added to the windows 7 machine and selected as the default printer and I have no problems printing to it from the Windows 7 machine except that I only recently found out that I cannot select from various photo paper sizes to print photos from the Windows 7 computer.  All various printing programes only give me a limited selection of paper sizes to choose from when configuing the printing - Letter, A4, A5 Envelope, Legal, etc.   The same programs on the XP machine offer the choice of various photo paper sizes to print to.  It seems as though all of the Photosmart configuration options are not available via the Windows 7 computer. Should I try to install the printer on the Windows 7 machine again, directly from a downloaded HP installation file?

    Hi,
    Well, looks like you have to install drivers on the Windows 7 machine (if supported) but I how do we know your printer to find out ?.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How can I print from a Windows PC to an AppleTalk networked printer?

    I have a Windows Dell laptop (NT w/SP 2) that normally prints on a Windows network at my office.
    At home, I have an AppleTalk network that includes a cable modem, router, various Macs connected by either Ethernet or wireless, and an HP 2100TN printer connected to that router via Ethernet. My AirPort Extreme also connects to that hub, so the network is a combination of Ethernet wired and wireless devices. When I connect the Windows laptop to this network (either wirelessly or by Ethernet), it cannot find the printer (although I am able to get to the Internet). I've tried to install Bonjour (Bonjour64Setup.exe) on the Windows machine, but it refuses (comes back with a message saying that "Bonjour is not a valid Win32 application").
    I am trying to find out how to get the Windows laptop to find and use the HP networked printer.

    Thanks for the various suggestions (the successful one was the HP Wizard).
    I couldn't find the IP address of the printer (the test page-- when printed directly from the printer-- does not show the IP address, nor does System Profiler), and the method used for the Airport Extreme USB printer was not necessary (although that may come in handy, some day).
    I downloaded the HP Network Printer Wizard which made the whole process fairly easy and worked. The HP Wizard found the printer and got the printer up on the Windows printer list. It really didn't need for me to give it the IP address (it found it on its own).
    Thanks.
    --bbadon

  • Is HP Photosmart Premium all-in-one C309n-s printer compatible with Windows 8.1 PRO?

    Is HP Photosmart Premium all-in-one C309n-s printer compatible with Windows 8.1 PRO?
    Operating System:  Windows Version 8.1 PRO
    When I upgraded from Windows 7 to Windows 8.1, my HP Photosmart Premium all-in-one C309n-s
    stop working.  Is this printer not compatible with Windows 8.1 PRO?  Is there any update for this?

    Hey,
    HP Photosmart Premium all-in-one C309n/g printer is compatible for Windows 8.1
    Please uninstall your printer's old software then install new one for windows 8.1.
    HP Photosmart Premium All-in-One C309 Series Full Feature Software and Driver :
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=mp-109711-1&cc=us&dlc=en&lc=en...
    Kevin_US_CA
    Make it easier for other people to find solutions, by marking my answer “Accept as Solution” if it solves your problem.
    ***Click on "Thumbs up" button to the left side of my post to say thanks!***

  • MacBook to print on a windows network

    I have proceeded with the install process to enable my mac to print to my windows network. However, when I attempt to give my username and password, nothing works. "Administrator" or my XP login will be accepted. Are there settings on the XP machine that need to be revised? Any assistance is appreciated.

    The apple link I provided above has the same procedure it is: http://docs.info.apple.com/article.html?artnum=301397 I would like to know why following the regular install method does not work for a lot of people. It will not authenticate unless you provide the IP user name and password in the advanced manual way. It is easy enough to do it manually with good instructions. The people helping need to be careful, they all seem to post the first iFelix site and do no get that it is the authentication that is messed up. I searched this site and many others and people just don't get that some of us for what ever reason have to use smb and install the user name and password manually. It almost drove me nuts. BDAqua helped me figure out the smb protocol on the networking thread.
    mark

  • Printing from Windows 8 to a shared printer on a Windows 7 machine

    WE have a a user that has a laser printer on A windows 7 machine that others in the office can access EXCEPT the one person on a Windows 8 machine. We have tried everything, but cannot get her to print to this printer. Says it cannot be found. What does
    Windows 8 need to see a printer on a Win 7 workstation. She does have access to network printers and her own.
    Thanks.

    We have the same kind of problem but a bit different.
    Dell Printer (used for years shared on a network) was moved to our Windows 7 machine plugged in via USB.  We only use a plain workgroup with no Domain as we also have Macs on the network.
    I have Macs using shared printer, a Windows XP using the shared printer, and even Windows 7 under Parallels on the Macs using the shared printer no problem.
    I had the lone Windows 8 laptop using the shared printer but then it just stopped working.  So I deleted it and now when I try to add it is want credentials and none work.  It will not connect to the shared printer on the Windows 7 machine.
    I have Windows 7 (which also has a couple shared drives that do work) set for No Homegroup and No Password for sharing - pretty much open as we are behind a Cisco Firewall to the outside.  No firewalls on the pcs.
    Not sure where to go from here...

  • V3 Printer driver on Windows Server 2012

    Hello there.....
    I have installed Print services on Windows Server 2012. I have read several forum and found that it is a best practice to install V3 drivers if workstations run on Windows 7.
    Our all of workstations have windows 7 so I want to install v3 printer drivers. we have printers of HP and Canon mostly.
    So can anyone tell me how can I get V3 drivers of HP Laserjet P4015 for example...
    I have installed a driver but found its v4.
    Please tell me how can I install V3 driver for HP, Canon printers.....
    Thanks
    Kind Regards
    Namvi

    You would need to use the V3 drivers that the vendors provide to Windows Update
    http://catalog.update.microsoft.com/v7/site/Home.aspx
    or from the vendors website
    Alan Morris Windows Printing Team

  • Is HP Smart Web Printing compatible with Windows 7 Ultimate 32 bit and Internet Explorer 8 and 9?

    Is HP Smart Web Printing compatible with Windows 7 Ultimate 32 bit and Internet Explorer 8 and 9?

    HP Smart Web Printing has been replaced with HP Smart Printing.  It does support Windows 7 and IE 6 to IE9.  See this page for information.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Problems Printing to Shared Windows Printer Via SAMBA (foomatic error 255)

    I can NOT print from my MacBookPro to a printer that's shared out from my Windows PC. Of course, printing to this same printer from my PC works fine.
    Please help me resolve this printing problem.
    Read on for more details regarding my printing woes!
    I can successfully setup my printer on the MAC side using the Printer Setup utility. I see the shared out printer on my MAC; I can pick the printer's manufacturer and model. Everything looks ok regarding the setup of the printer on the MAC side.
    However, when I try to print a file from the MAC, the printer never prints. The print job appears to get queued on the MAC side. However, after a few seconds, the printer queue displays "foomatic-rip stopped unexpectedly with error 255" (if I selected a foomatic printer driver from the hpijs). Otherwise, it says "NTSTATUS_NOMEMORY" error (if I selected a gutenprint driver instead).
    The PC's Windows event logs show no problems. Indeed, the Security event log shows successful authentication & access to the printer.
    The MAC's CUPS error_log displays the these error messages:
    GutenPrint fails with NTSTATUS_NOMEMORY error, then says Cannot connect to SAMBA host
    hpjisGhostscriptFoomatic fails with "The process 'foomatic-rip' stopped unexpectedly with status 255"
    Later, I will post the exact entries from this log (I am currently separated from my MAC laptop until later this evening).
    My Apple MacBookPro is running MAC OS X 10.4.11 ("Tiger"). The printer is an HP DeskJet 5150 connected via a USB port to my DELL 8400 PC. This desktop PC is running Microsoft's "Windows XP Pro Service Pack 2").
    Based on reading other posts (here) and at the Linux Open Foundation (printing), I have already done the following:
    Installed gutenprint;
    Installed foomatic (foomatic-rip v3.42.2.15);
    Installed ghostscript (espgs v7.07.1); &
    Installed hpijs (hpijs v2.7.10).
    NOTE: This is NOT the same problem that I posted earlier regarding inability to print to a shared printer with Leopard (MAC OS X 10.5.0). Today's posting deals with my inability to print to the shared printer from Tiger (MAC OS X 10.4.11).
    NOTE: This may be a "red herring" but you may need this additional background to help resolve my printing problem. Originally, I ran "Tiger" (MAC OS X 10.4.10) on my MacBookPro laptop. Of course, networked printing worked fine at this point. On October 28, 2007, I upgraded to "Leopard" (MAC OS X 10.5.0). Leopard was a "disaster" for me (printing, networking & many other problems). On November 9, 2007, I "punted" and re-installed "Tiger" (MAC OS X 10.4.10) from Apple's original CD. On November 15, 2007, I upgraded to MAC OS X 10.4.11 via Apple's software update utility. I vaguely recollect that networked printing was working after I returned back to Tiger.
    /s/
    Tony H.

    As promised in my initial post regarding my printing problem, here are the actual error messages displayed in the Print Queue (Hp5150) and the "cups" error_log when I try to print any file to my HP 5150 that's directly connected to my DELL PC (Windows XP Pro) but shared out so that my MacBookPro should be able to print to it.
    Printer Queue Hp5150 window displays:
    =========================
    The process "foomatic-rip" stopped unexpectedly with status 255.
    /var/log/cups/error_log displays:
    =====================
    I [04/Jan/2008:20:25:17 -0500] Job 3 queued on 'hp5150' by 'anthonyhackenberg'.
    I [04/Jan/2008:20:25:17 -0500] Started filter /usr/libexec/cups/filter/cgpdftops (PID 681) for job 3.
    I [04/Jan/2008:20:25:17 -0500] Started filter /usr/libexec/cups/filter/pstops (PID 682) for job 3.
    I [04/Jan/2008:20:25:17 -0500] Started filter /usr/libexec/cups/filter/foomatic-rip (PID 683) for job 3.
    I [04/Jan/2008:20:25:17 -0500] Started backend /usr/libexec/cups/backend/smb (PID 684) for job 3.
    E [04/Jan/2008:20:25:17 -0500] [Job 3] Connection failed with error NTSTATUS_NOMEMORY
    E [04/Jan/2008:20:25:17 -0500] [Job 3] Unable to connect to SAMBA host, will retry in 60 seconds...Insecure $ENV{PATH} while running setuid at /usr/libexec/cups/filter/foomatic-rip line 215.
    E [04/Jan/2008:20:25:17 -0500] PID 683 stopped with status 255!
    I [04/Jan/2008:20:25:17 -0500] Hint: Try setting the LogLevel to "debug" to find out more.
    E [04/Jan/2008:20:26:17 -0500] [Job 3] Connection failed with error NTSTATUS_NOMEMORY
    E [04/Jan/2008:20:27:17 -0500] [Job 3] Unable to connect to SAMBA host, will retry in 60 seconds...ERROR: Connection failed with error NTSTATUS_NOMEMORY
    E [04/Jan/2008:20:28:17 -0500] [Job 3] Unable to connect to SAMBA host, will retry in 60 seconds...ERROR: Connection failed with error NTSTATUS_NOMEMORY
    Again, the system Event logs on the Windows XP side show no error messages. In particular, the Security Event Log shows that authentication was successful; so, the MacBookPro's client process was granted access to the printer on the DELL PC side of the transaction.
    Message was edited by: ClassicalApproach

  • Firefox crashes on Windows 7 when printing to a Windows 7 network printer.

    On Windows 7 running Firefox 3.6.10, I cannot print to a Windows 7 network printer. Firefox crashes every time as soon as I hit print.
    However, the situation is very specific. I can print from Windows XP using Firefox 3.6.10 to a Windows 7 network printer. I can also print from Windows 7 using Firefox 3.6.10 to a Windows XP network printer. The only situation that doesn't work is using Firefox and printing from Windows 7 machine to Windows 7 machine.
    Firefox is also the only program that does not print. I can print using Internet Explorer, Google Chrome, MS Word, MS Excel, and every other application just fine. Firefox is exclusive in that it is the only program that crashes and refuses to print. The drivers that are being used a PostScript drivers.
    I have tried multiple versions of Firefox from older ones to the Firefox 4 beta and the program crashes every time.
    Again, the only time it crashes is printing from a Windows 7 client computer to a Windows 7 network printer. Printing from XP to Windows 7 and from Windows 7 to XP works.
    Any help would be greatly appreciated. The only program I've noticed the problem with is Firefox, so I'm assuming it's a problem at the application level.

    Here is the Crash Report for a user more experienced at reading Crash Reports than I am: <br />
    http://crash-stats.mozilla.com/report/index/45f47e99-ea8e-449f-aa1e-6399e2101014
    Here's a search for that particular Signature - [http://crash-stats.mozilla.com/report/list?product=Firefox&query_search=signature&query_type=exact&query=OPBinaryCookedPortWrite&date=10%2F14%2F2010%2014%3A00%3A00&range_value=1&range_unit=weeks&hang_type=any&process_type=any&plugin_field=&plugin_query_type=&plugin_query=&do_query=1&admin=&signature=OPBinaryCookedPortWrite OPBinaryCookedPortWrite] <br />
    Looks like a Windows problem, but not restricted to Win7 or 3.6.10 - there's one on Vista SP2 with Firefox 3.6 and another with 4.0b6 on Win7.

  • Printing through a Windows computer.

    I'm working on a 1GHz Power Mac G4 desktop that is connected with Ethernet to a Linksys BEFW11S4 wireless router. The printer is connected to a Dell Dimension 4300 by USB. The question for me is, even though I can get the printer to show up in my printer search list, I can't get anything to print off of it. Does anyone know a possible solution? Any ideas would be greatly appreciated. If you have any questions about details or anything, just leave me a message. Thanks for your help!

    I have a Mac Mini running Leopard and I print through a Windows XP computer with printer sharing turned on. My printer is a Samsung ML-1710.
    The printer shows up in the network as expected, but initially I had a problem in which the job was sent, the printer spun up then stopped dead.
    I tracked the problem to the driver setting on the Mac, which had defaulted to Generic Postscript Printer. Since Leopard had no driver for the ML-1710, I got it from the Samsung website, installed it, and changed the print driver to the proper one. Then it worked fine.
    I guess the important thing is that you are running the correct driver for the printer, as unlike WinXP, it doesn't install a network printer driver for you.

  • Printing to a Windows Shared Printer in Windows Domain Stopped Working

    If anybody can shed some light on the problem below I would be highly appreciative. I have tried every suggestion I've found on ways to fix this problem, including postings found on this forum, without success.
    I use able to Print to a Shared HP Laser Jet printer one a Windows 2003 Server machine, which is part of a Windows 2003 Domain. It has been working faultlessly until about a 2 weeks ago. I have had a number of errors including unable to Connect but the Error I get constantly now is:
    +Unable to connect to SAMBA host, will retry in 60 seconds...ERROR: Connection failed with error NTSTATUS_NOMEMORY"+
    I have reset the password of the windows user that originally made the connection when the computer was set up and this password had special characters. After reading various posts I have tried:
    1. Reseting that users password without special characters, deleting the printer and adding it back in using the same user and the new password. The same user can map and connect to windows Shared Directories on the same Server and open and edit files
    2. I have reset the Keychain to make sure it was using the new password. Again deleted and re-added the printer.
    3. Created a new user both on the domain and one the print server deleted and re-added the printer using each user while also reseting the key chain
    4. Tried the Advance option on the Printer Setup Utility using the following SMB URL format,
    smb://user:pass@Domain/Machine/Printer where, the domain is called "home", the machine name is "Devserver01" and the printer share name is "HPLaser" resulting in a smb URL of smb://shanep:xxxxx@Home/Devserver01/hplaser.
    None of the above work!
    So as a new MAC user I have absolutely no other ideas of where to look for additional information on what is happening i.e. where do you look for log files that may contain additional detail.
    Can anybody assist on suggesting any other things to look for or check?
    Thanks
    Shane

    Hi Greg,
    Thanks of the tips. I have just managed to get it working and I didn't use the LPD method but tried a few different smb URI's.
    Here's what I found worked.
    1. I created a standard user account on the Windows 2003 server on which the printer is connected and shared, i.e. a non Domain user name that is local to the server only and not the domain
    2. I then used this user name and password, along with the IP address of the server in the URL i.e.
    smb://user:password@IPofserver/hplaser.
    3. Printed a test page successfully
    I then tried variations of a theme using username and passwords on the domain, changing the @workgroup/server/printer with no success.
    I could however replace the IP address with simply the @Server/Printer combinations using he local user name and password successfully.
    I also installed apple and Unix printing and file services so whether this made the difference I'm not sure.
    Interestingly I tried to add the mac to the LDAP/Active Directory and couldn't successfully bind to the directory. Not that I'm an AD expert, but I have configured a few Java applications to use LDAP/AD authentications and groups of late so this problem is a little unusual, but that aside, thanks for the pointers, Printing problem solved. now to solve the AD one
    Shane

  • Printing to a Windows shared printer via SAMBA

    I'm trying to setup my mac to print to a printer shared via a Windows PC on my network. I have gone into system preferences / print&fax and added a printer, used the "Advanced" settings on the toolbar, chosen SAMBA and entered the address of the printer as smb://IPADDRESS/printername
    When I try to print to this printer, it asks for a username and password. I enter it and then the document briefly appears in the printer queue and then disappears as if it has printed successfully. The document however never appears in my Windows printer queue or actually prints.
    CUPS does not return any errors in the CUPS log file. CUPS actually says the printer is idle and accepting jobs.
    A friend can print from a windows PC to the printer by using the address \\IPADDRESS\printer name in the manual windows printer setup (the printer does not show up in the browser).
    I can also connect to the computer using Leopard's built in SAMBA networking by accessing smb://IPADDRESS so I know the server is active on the network and my username and password work.
    Does anybody have any ideas why I am not getting an errors and it's still not working?

    Well, that isn't too useful. Try this instead: Adding a printer shared by a Windows computer via SMB/CIFS.
    You may find more by selecting Mac Help from the Finder's Help menu and searching for articles by keyword.

  • Printing to shared Windows printer fails after Yosemite upgrade

    Running Mountain Lion had a working shared printer from Windows 7 Pro - a Canon MX310.
    After upgrade the printer is still there but trying to use it results in "Support Code : 306 A communication error has occurred..."
    Tried deleting the printer then re-adding. The OS X printer app finds the printer in the windows workgroup, appears to have a little chat then says its added ok. Same Error.
    Tried a reset of the mac printing system - same.
    Printer is working on the host PC and from other network windows PC.
    Anyone else seen similar issue?

    I can't claim any experience with this printer. I am going on what the "specs" say should work.
    There are three software pieces needed to set up this printer. For the first two, you will need to download and install both the Foomatic-RIP software and the ESP Ghostscript software from <http://www.linuxprinting.org/macosx/foomatic/>.
    For the third item, you will need to download the PPD for this printer from <http://www.linuxprinting.org/show_printer.cgi?recnum=Canon-BJ-200>. Place the PPD in the following folder (make any folders that are not already on your system):
    /Library/Printers/PPDs/Contents/Resources/en.lproj
    This setup will use the bj200 device that is built into Ghostscript. The notes that I find in the device driver indicate that this is using the BJ-10 command set. The manual for the bj-200e shows that this is one of the languages it can use. There might be some DIP switches you need to set to make things compatible with this command set and/or the line spacing set forth in the device driver.
    Let us know how this goes.
    Matt
    Mac Mini G4; B&W G3/300    

  • Printing to a Windows Print Server

    I consider myself pretty computer literate however I am comletely baffled at how to connect to a print server running Windows 2000 using my MacBook at work.
    I have tried going into:
    System Prefs > Print & Fax > add printer > more printers
    which brings me to two pull down menus that have options the options:
    "Apple Talk, Blue Tooth and Windows" printing as well as "Canon IJ Network, Epson Apple Talk & Wirewire, Espon TCP/IP etc" The second drop down says "Network Neighborhood" or "Workgroup".
    I am pretty sure I have tried every combo of these and nothing recognized the two printers on the server (Samsung ML-2150 and HP Business Inkjet 1200).
    I made sure I have the most recent version of both drivers for Tiger 10.4.7 and I can connect (and print) to each printer directly using USB but not through the network.
    I am using Airport to do so but I have used Ethernet cable as well to test and no luck. I am also hooked up through a Linksys WRV router and tried using a second router hooked up only to myself and the printer.
    Despite all of the above, please feel free to dumb down the suggestions as networking is not my strong suit.
    Any suggestions would be greatly appreciated. I can update anyone with more info if there is something I have left out.
    Thanks

    Hi,
    I have come across several of your posts in trying to resolve a problem connecting to a printer on a G5 from Windows 2000. This post I could reply to.
    First off, I think your documentation is great.
    I have read http://www.ifelix.co.uk/tech/3000.html to try and connect from a Windows 2000 box to a Mac G5 running 10.3. I have followed it to a 'T', but I get the message that I can't connect to the printer -- either the name is wrong or the printer is disconnected. Checked each case, and keep hitting the wall.
    I have been able to identify the Mac from the Windows box, and connect to a directory, but try as I might, the network printer will not show up in the network neighborhood. Typing in the name (queue_name) has not worked either.
    I checked the /etc/smb.conf and printcap files. Should I be manuall inserting the name of the printer into the smb.conf file?
    Stumped.
    Any ideas? Very frustrating bit this is.
    Thanks,
    dbrktkt
    g5   Mac OS X (10.3.9)  

Maybe you are looking for