Mac OS X - Printing - PrinterGraphicsConfig.getDefaultTransform() throws a NullPointerException

Hello guys, I currently try to get our Swing application working on Mac OS X and I found one problem which blocks me. Our application usese the java.awt.print package to generate print-outs.
One very important information for us is the printers used DPI/PPI setting. We've found a long time ago a tutorial which uses the given Graphics object of the java.awt.Printable.print(Graphics, PageFormat, int) method to get this neseccary information.
The implementation of our looks like the following:
* @see java.awt.print.Printable#print(java.awt.Graphics, java.awt.print.PageFormat, int)
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
  if (pageIndex != 0)
  return Printable.NO_SUCH_PAGE;
  Graphics2D graphics2D = (Graphics2D) graphics;
  // get the current scale
  AffineTransform defaultDeviceTransform = graphics2D.getDeviceConfiguration().getDefaultTransform();
  double deviceScaleX = defaultDeviceTransform.getScaleX();
  double deviceScaleY = defaultDeviceTransform.getScaleY();
  * this method gets an graphics from the printer which is already scaled to the desired resolution and therefore
  * the dpi can be calculated by the scale of the transformation.
  * -> no other way to determine the dpi were found
  double dpi = deviceScaleX * 72;
  System.out.println("The Printer uses the following DPI setting: " + dpi);
  myPrintingMethod(graphics2D, dpi);
  return Printable.PAGE_EXISTS;
This way to get the DPI/PPI setting of the printer works perfect if the operating system is Microsoft Windows. But in case of the Mac OS X throws the Line 13. the following NullPointerException:
java.lang.NullPointerException
at java.awt.geom.AffineTransform.<init>(AffineTransform.java:488)
at sun.print.PrinterGraphicsConfig.getDefaultTransform(PrinterGraphicsConfig.java:101)
at com.intergraph.web.plugin.printing.PrintableDocument.print(PrintableDocument.java:122)
at sun.lwawt.macosx.CPrinterJob$6.run(CPrinterJob.java:697)
at sun.lwawt.macosx.CPrinterJob.printAndGetPageFormatArea(CPrinterJob.java:707)
at sun.lwawt.macosx.CPrinterJob.printLoop(Native Method)
at sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:299)
at com.intergraph.web.plugin.printing.PrintEngine.print(PrintEngine.java:177)
at com.intergraph.web.plugin.printing.controller.PrintDocumentJob.run(PrintDocumentJob.java:41)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I tried to find a workaround but I wasn't sucessful and I only found the following thread from 2008 Simple Printing example that raises many questions .... the result of this thread is not the same but it describes the same problem...
Does anybody of you know a way to figure out the DPI/PPI setting of a printer?
I'm tested it with:
JDK 8u5
OS X 10.9.4
Thanks in advance!
Best Regards,
Steve

I tested it with the following printer
Konica Minolta bizhub C353

Similar Messages

  • I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. Any tips on how to do this?

    I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. I installed the current Bonjour printer services software on the Windows machine, and separately installed the driver software for the Epson printer on the WIndows machine.  Running the bonjour wizard, I get an alert saying 'I don't have sufficient access to my computer to connect to the selected printer'.
    The printer has 'sharing' turned on from the Mac end; this works with a Powerbook via the wireless connection.  Sharing is also turned on in the Windows printer control panel for this printer (under properties).  The Mac is a G5 running 10.5.8.  When I try to print a page from the Windows machine it gets hung in the print queue.
    Any advice how to proceed would be appreciated!
    thx,

    I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. I installed the current Bonjour printer services software on the Windows machine, and separately installed the driver software for the Epson printer on the WIndows machine.  Running the bonjour wizard, I get an alert saying 'I don't have sufficient access to my computer to connect to the selected printer'.
    The printer has 'sharing' turned on from the Mac end; this works with a Powerbook via the wireless connection.  Sharing is also turned on in the Windows printer control panel for this printer (under properties).  The Mac is a G5 running 10.5.8.  When I try to print a page from the Windows machine it gets hung in the print queue.
    Any advice how to proceed would be appreciated!
    thx,

  • HT2250 I have been able to get my MacBook Pro to print wirelessly through my Airport device. How do I make it so other computers (non-Mac) can also print wirelessly as well? They are able to connect through my wireless network but can't print.

    I have been able to get my MacBook Pro to print wirelessly through my Airport device. How do I make it so other computers (non-Mac) can also print wirelessly as well? They are able to connect through my wireless network but can't print.

    Well, you could install the drivers to the wireless printer in you other computers.
    blue apple > System Preferences... > sharing
    check printer sharing.

  • I have a macbook pro. i have a photosmart 7510. we just bought a new windows tower and the printer works wireless for us, but now the mac does not print anymore wirelessly. i keep getting a message Network host 'HPE93F2A.local.' is busy. what can i do to

    I have a macbook pro. i have a photosmart 7510. we just bought a new windows tower and the printer works wireless for us, but now the mac does not print anymore wirelessly. i keep getting a message Network host 'HPE93F2A.local.' is busy. what can i do to

    it is a windows 8

  • HT3500 I have a new epson wireless printer but can not get my Mac laptop to print to it even after doing the installations.  What do I need to do

    I have a new epson wireless printer but cnannot get my Mac laptop to print to it.  Any suggestions

    Can you find your printer in Print & Fax?

  • Hello - how do i get my mac pro to print in colour

    Hello - how do i get my mac pro to print in colour - i am using HP Envy 120 and can not print in colour. when testing the printer, the printer prints in colour, but trying to print from the mac book pro - it prints in black and white. i can't find an option that

    I know nothing about your printer. However, to use it properly you must Add the printer in Print & Scan preferences.
    See OS X Mavericks- Set up a printer. Also, consult the printer's user manual. With the proper setup the printer should print color or b/w automatically. If you have further problems you need to start with the printer HP's tech support.

  • I want to set up two I Macs and a printer wirelessly thru AP Extreme. IF I want to sync only of them to my I phone,is that possible?

    I want to set up 2 I-Macs and a printer thru Airport Extreme. How do I set up a sync with one I Mac,  for my I phone, but not the other?

    You will sync your iPhone to the iMac by using a connecting communication cable supplied with the iPhone.
    Connect the iPhone and communication cable to the iMac that you want to use.

  • PDF files created in Acrobat Pro X for Mac will not print correctly on Windows - text is missing

    I recently created a PDF file with pictures and texts in Acrobat Pro X. However, when I send it to my coworkers (who work on Windows computers), the printed file contains only images, and no text. I am using Century Gothic - a font that is installed on these Windows computers. When they open the files, they can see the text and everything exactly as it is meant to be. However, upon printing, the text disappears completely.
    We are using a Konica Minolta Bizhub printer to complete these printouts. When I print from my computer (the Mac), the files print perfectly on this printer. However, when using the same printer, a Windows user cannot print the text in the PDF's.
    Has anyone else run across this problem? I am thinking of trying to embed fonts, however it doesn't seem like it would make much of a difference (since the fonts show up fine on a Windows computer anyways). Is there a known issue with printing PDF's on a Konica Minolta printer?

    The archive format you used embeds all fonts, as does Press and Print type job settings. The standard job settings does not embed all fonts and that might be where the problem was.

  • Can't print from Mac to Windows printer

    I have a wireless network of 3 computers and a printer. One is a desktop running XP with the printer attached. The other is a laptop with XP. And the last is a MacBook with 10.4.11.
    I can print from both computers running XP but I can't print from the Mac. The Mac sees the printer and I can add it and try to print from it. When I try to print I get the error message:
    NTSTATUS_NOMEMORY
    I later get the "Unable to connect to SAMBA host, will retry in 60 seconds" message too.

    Be sure the printer name assigned in Windows is not more than 11 alphanumeric characters. Long names with punctuation and the like are known to cause problems.
    Look at:
    Mac OS X 10.4- Can't print to a printer shared by Microsoft Windows;
    Mac OS X- Cannot locate a shared Windows printer;
    Mac OS X- How to manually add a Windows shared printer;
    Setting up to print to a printer shared by a Windows computer via SMB;
    And finally this:
    Monday, July 24 2006 @ 11:00 AM PDT
    Tutorial: Resolving common printer problems
    Mac OS X offers a robust printing system with built-in support for hundreds of devices from a wide body of manufacturers. It's not without flaws, however, and printers often become unrecognized or non-functional after a significant Mac OS X update. Printers connected through hubs or AirPort base stations can also exhibit some frustrating issues.
    Below is a run-down of the most generally successful printer workarounds. Keep trying until one of them sticks.
    Use Printer Setup Repair This tool lets you verify properties of the root user, the Printing Services (lp) user, and Print Operators (lp) groups, reset the printing system, perform CUPS maintenance and more. Run through its set of maintenance tasks before delving into further printer troubleshooting. See how to use it in this article.
    Re-install CUPS If you are experiencing printer issues after applying an incremental Mac OS X update, problems may have occurred with your CUPS installation during the update process.
    The file is available from this Web site: http://www.cups.org/software.php, and is labeled cups-1.2.1.dmg
    Delete then re-add printers/Reset printing system Open Printer Setup Utility, located in Applications/Utilities and look at the "Printer List" Highlight and delete all entries.
    Alternatively, go to the "Printer Setup Utility" menu at the top of the screen and select "Reset Printing System".
    Click the "Add" button and re-add your printer(s).
    Gutenprint and usbtb Some users have been able to resolve printer communication issues by installing the excellent open-source Epson printer drivers available as part of the Gutenprint package (formerly known as Gimp-print) and usbtb, a CUPS back-end for USB printing.
    Remove non-required drivers Removing extraneous drivers from /Library/Printers(name of manufacturer) can sometimes resolve printer issues. Remove files that are for other models than your own.
    Re-install drivers Re-installation of printer drivers from original media or from a Web download (either directly through the manufacturers site or via a search by model/manufacturer on VersionTracker) can resolve some printer issues.
    Try disconnecting from network In some cases, LAN-connected printer, seemingly broken by the Mac OS X update can restored to normal operation by simply disconnecting the device from the network then re-connecting it.
    "Communicator Error" -- try power cycling If you receive a "Communication Error" message when attempting to print after updating to Mac OS X 10.4.5, the first workaround you should try is power cycling the printer, as well as disconnecting then re-connecting it to the Mac.
    Connecting directly to the Mac If you are having printer problems and are using an external USB hub, try connecting the printer directly to your Mac.
    One reader who had success with this method writes:
    "Unfortunately the update to Mac OS X 10.4.6 has eliminated the ability to use my Lexmark Z600 series USB printer on my iMac G5 20" iSight (rev C).
    "I resolved the problem via the following: I unplugged my external USB hub and plugged the printer directly to my computer."
    Disconnect from AirPort and reset For those who are using printers connected to an AirPort Express, Extreme or another wireless device with USB connections, you might want to try the following:
    Disconnect the printer from the AirPort unit (or other router)
    Wait a few minutes
    Plug it back in
    Restart the base station unit
    Check for your printer to appear in AirPort Admin Utility (located in Applications/Utilities)
    Print one copy In some cases, using print one copy instead of the standard print command can result in elimination of crashes that occur during printing.
    Try IP printing instead of AppleTalk Some Macs are unable to see AppleTalk printers that are located on the local AirPort (or other wireless) network. Several users have been able to workaround this issue by using IP printing instead of AppleTalk.
    Last resort -- Archive and Install As a last resort, try performing the somewhat tedious Archive and Install process, then re-upgrading to Mac OS X 10.4.7. This has solved some otherwise inexplicable printer issues for MacFixIt readers.

  • My Epson photo 1280 will only print 1/2 of a page from a document in Pages program. First print was fine. Have printed out a Mac templet and printer does same thing. Cleaned heads, checked nozzels etc. Any ideas?

    My Epson photo 1280 will only print 1/2 of a page from a document in Pages program. First print was fine. Have printed out a Mac templet and printer does same thing. Cleaned heads, checked nozzels etc. Any ideas?

    Hello, I have exactly the same problem. I could have written the same text. And I have'nt found solutions. Except, perhaps, change this printer (and quit HP?).
    Any suggestions would be really much appreciated.
    Thank you for your possible responses.

  • What is the best bluetooth adapter from a mac to a printer that is not wireless?

    what is the best bluetooth adapter from a mac to a printer that is not wireless?  Using a Canon Pixma 850

    How to burn MTS to DVD on Mac OSX:
    http://www.iskysoft.com/create-dvd/mts-to-dvd-mac.html

  • Trouble printing from mac to windows printer

    I purchased my first mac last weekend and successfully set it up on my home network which is shared with my windows xp desktop. My HP deskjet printer is shared on the network through my desktop windows pc (not on a separate printer router). My mac recognizes the printer on the network but it prints meaningless garb when I ask it to print a document. Any suggestions to rectify my printing problem???
    iBook G4   Mac OS X (10.4.3)  

    I followed the instructions at http://www.ifelix.co.uk/tech/3012.html and am having the same issue. Whether setting up manually or using Bonjour, it seems that you have to select an Apple Driver. The problem is that the Windows 7 does not provide Apple drivers. Luckily, I have an old XP installation CD so I can access the printer drivers I need, but because I already installed the printer drivers from my printers CD Windows will automatically install with that driver, not giving me the "have disk" option.
    So I tried to install with Bonjour again, which allowed me to pull up the drivers from teh XP installation disk, but then gave me an error that I didn't have permissions to install the selected printer.
    So I deleted the Canon driver for my printer from Windows 7 and went through the process described at http://www.ifelix.co.uk/tech/3012.html again. This time I was able to select the Apple Color Laserwriter printer from the XP installation CD, but I got an error message saying that Windows was unable to find an appropriate driver.
    At this point, after a couple hours trying to do a simple file share, which should only take 30 seconds, I'm giving up being able to print to a printer connected to a mac from my Windows 7 laptop. Now I have to open files on the mac from the network file share to print.
    Mixed having both Macs and Windows machines on the same network is a recipe for a headache.

  • Mac Lion OS print driver for hp color laser jet 1600 & business inkjet 2200

    I just brought a Macbook Air (13in) with the new OS Lion.  I however have a HP Color Laserjet 1600 and Business Inkjet 2200 that I love, but can't find a printer driver for either.  So, my questions are, does anyone know if:
    1)  there is going to be a mac lion os print driver for hp color laser jet 1600 & Business Inkjet 2200; or
    2)  is there another way to print to them (i.e., the 2200 uses HPA instead of PS and the 1600 uses PCL)?

    Any suggestions re correct driver for windows 7 and HP 4600dn?

  • Is there a Mac-compatible wireless print server?

    This is a variation on a theme many have touched upon. I want to have my Airport Extreme wirelessly connected to two printers (B&W laser, and color inkjet) currently connected by USB cables, stretched to 16' limit. Printers can't be moved conveniently to a closer position. I bought a $100 NetGear wireless print server WGSP606 (two USB ports) at CompUSA yesterday after staff there said it would work with Macs. Alas, it doesn't. The printers are not wireless models; the wireless print server supposedly (if Mac-compatible) would effectively make them wireless. From the various posts I get impression that an Airport Express might work, but could it serve two printers? Anyone know of a Mac-compatible wireless print server? Or have a workaround suggestion? Any help much appreciated.

    I'd say if the print server supports standard printing protocols, then OS X will work with it. But there are issues you should learn about.
    The network comm protocols you see in Printer Setup Utility are part of the CUPS system. Very few (only Brother so far) non-postscript printer drivers work correctly with the CUPS system. The manufacturers have provided OS 9-style drivers that have USB comm written into the driver, limiting you to USB use only. Postscript printers don't have this issue because they don't need a driver, just a PPD. Apple tried to get around this issue by including Gimp-Print open source CUPS drivers, but the models supported are limited. So, the first issue is - is a CUPS driver available?
    Protocol setup on OS X is the next issue. For Windows, there is autosetup software for nearly every print server sold new. We don't have that software on OS X, so we need to enter the correct info into Printer Setup. The IP > IPP and IP > LPD protocols require a print-server-specific queue name together with IP address to route data to the printer. Because of the Windows autosetup software, help desk people at Netgear may not even know this basic info. But nearly all print servers correctly support the standards and the device queue name can be found in the print server manual.
    The advantage of Airport Express and Extreme as print servers is that Apple uses the airport/Bonjour software to redirect USB output from the computer to the USB on the Express/Extreme. Kind of avoids the printer driver issue but also takes away some standard IP protocols (only HP jetdirect is supported for non-Bonjour printers).
    Sorry for the mini-lecture. Hope this helps.
    (Airport Express/Extreme is only for one printer)

  • Why does Mac keep installing printer when already installed?

    I have a client that has Mac Air running Mountain Lion 10.8 connected to LAN via WiFi.  The printer is an Epson WF-3520 connected to LAN via ethernet cable.  The router running pfSense has Bonjour services allowed between LAN and WiFi.  The Mac keeps re-installing the printer and increments the printer queue each time.  The highest enumeration has gotten to -57 after the printer name.  Other Macs in the same LAN do the same thing.  Trying to figure out why the Mac forgets the printer is already installed.  I have done everything I can think of except re-setting the printer system.
    Thanks for any pointers.

    FYI- in case this can help others.  What I eventually did was move the printer off the ethernet cable and made it wireless too, like the desktops clients in the office.  No more problems with the printer increasing enumerations on the Macs.  Evidently the router/firewall was creating some issue even though there are not rules blocking traffic between the 2 wired versus wireless clients interfaces.

Maybe you are looking for

  • Some I/O problems, need help!

    problem 1: i have a file a.txt content of a.txt 12 13 15 ...integer and i want to use an string array to store each integer , how to know the proper size of the array to store them? problem 2: How do I write an integer array to a file b.txt like this

  • Automatically update table when database make any changes

    Hi Experts, I want to create one table in the database that table but values get inserted into that table automatically when the database make any changes (i.e if you insert/update/delete any values in any table in the database) how should i create t

  • Validation not in sequence

    Hi, I have a form and 10 fields on that form say field1 to .. field10. User need to show the validation in sequence. for ex. if i don't enter any value in any field and click on save, user should see all validation error but it should point to field1

  • Getting error code 150:30 after transferring data from iMac to iMac

    Hey there, I have just gotten a new iMac and have migrated my data from my old one to my new one. When I open After Effects CS4, I get error code 150:30, a licensing problem. I'm sure it has something to do with duplicate copies of the program. How c

  • Headphone jack gone crazy

    All of the sudden the sound coming through the headphone jack is corrupted. If i unplug the headphones, the music sounds perfect (through the built-in speakers). When i plug the headphones again it sounds like if the audio files were corrupted. I alr