3 Replies Latest reply on Sep 3, 2010 8:31 AM by 843810

    Printing an existing PDF file

      I have been looking around everywhere to find a solution to this problem but just can't find anything. I am generating PDFs using iText. Once I have the file created I simply want to print it, which is apparently impossible without buying a 3rd party library.

      Has anyone found a way to take an existing pdf file and send it to a specific printer.

      To make it very clear (as in most other threads people don't seem to understand what the asker is actually saying)

      I have a file (C:\a.pdf)
      My default printer is called "abc"
      I have a 2nd printer called "xyz"

      I want to print C:\a.pdf to printer "xyz".

      Currently I am printing via acrobat but it's crap. It refuses to close after printing which is the main problem and I don't want to look up the processes and kill it as this is nasty.

      Surely someone, somewhere, has found out a way to say "print this file" from java! I don't care if it is a lot of code. I don't mind using an external library. It must work on windows, linux and crapple macs otherwise I'd just use FoxIt instead of acrobat.

      I have experimented with MANY different methods. The one found here (http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/) seems to be the best, however, the first page in a PDF seems to print portrait regardless of whether or not it's portrait. All following pages are then landscape. It was almost an amazing solution! If anyone has any ideas on that it would be much appreciated
        • 1. Re: Printing an existing PDF file
          Hi !!!!!!!!!!!

          Can you read spanish ?? if your answer is yes check this link: http://www.jmsanz.net/?p=194 if no tell me and I'll explain the code.

          Greetings !!!
          • 2. Re: Printing an existing PDF file

            I found jpedal on my searches but it's not an option due to the cost. Seems expensive considering all I want to do it send an existing PDF to a printer :S I really don't understand how it's so difficult to be honest. PDFRenderer on the dev.java.net site looks really promising but has a few issues. It doesn't seem to be active any more though which is disappointing.

            I think I have solved the problems I was having with it. I will post here after I have done some testing to say exactly what I have done
            • 3. Re: Printing an existing PDF file
              JPedal is licensed on a unlimited site usage or OEM basis and it includes 12 months support and all new releases in the year. It does printing, extraction, PDF to images and provides a viewer as well.

              PDFRenderer does not support compressed PDF objects so it will not work on all PDFs.

              If the printer supports PDF directly you can use JPS to print to it - otherwise you need JPedal or a similar library to print it.

              You could also call something like Ghostscript from Runtime.exec()