-1

For the past month or two, I have been tearing my hair out with this. I need to print multiple copies of a PDF file in Java. I have tried multiple libraries, including Apache PDFBox, IcePDF and others, I have tried many codes I have been able to find, but the result is always the same, both on Windows and Linux, only one copy of PDF is printed, be it to PDF or to a regular printer. I have also tried a number of printers, even one that was enterprise grade, so that I was able to rule out the incompatibility of my printers. Has anyone ever encountered this problem? I would like to use system calls to programs like Adobe Reader/Foxit Reader as a last resort. Thank you for all your help :)

// What I need is a way to print multiple copies in one print job, not in a loop creating multiple print jobs, sorry that it was unclear from the original post.

kubik369
  • 11
  • 1
  • 1
  • have you tried the Desktop class – Huang Chen Jul 28 '15 at 20:08
  • Yes, I have, but I was not able to find a way to print more than one copy without looping and sending 50 printjobs to the printer. – kubik369 Jul 28 '15 at 20:11
  • is that not what you want? – Huang Chen Jul 28 '15 at 20:12
  • No, I want to be able to print multiple copies in one print job, because it would take ages to print for example those 50 printjobs as printer stops after one job, then it has to heat up for another 10-20 seconds over and over again and with one printjob, it just prints continuosly. – kubik369 Jul 28 '15 at 20:17
  • Well it seems like you know how to load your pdf's (let's say 50 of them). You should create another pdf object and append all your 50 pdf's to that one pdf object. Then you can just print that single pdf. – Huang Chen Jul 28 '15 at 20:19
  • Yes, I have thought of that, but the PDF merging in Java has ridiculous memory consumption, for a 90kb PDF it takes up almost 2GB of RAM while doing 10+ copies, which is not ok as the program will possibly have to run on a PC with only 2GB of RAM total. – kubik369 Jul 28 '15 at 20:26
  • I've done this with excel files well over 90kb on a 2gb machine and this is simply not true. Instead of thinking about it, I suggest you actually do it. – Huang Chen Jul 28 '15 at 20:31

1 Answers1

0

Have you tried Gnostice PDFOne (for Java)? You can use its setCopies() method. http://www.gnostice.com/nl_article.asp?id=160&t=How_to_Print_a_PDF_Document_in_Java

PDF printing dialog in PDFOne Java

gn1
  • 526
  • 2
  • 5