We have a need to batch print 3,000+ PDF documents every month. The PDF documents are stored as byte arrays in a table with column type MEDIA (BLOB). What is the best method to print the PDFs as a batch process?
We are able to print a single PDF document using Adobe Reader (version 10) launched as an external Windows process. However, when we attempt to batch print multiple PDF documents, the first document prints, then Adobe Reader hangs the solution until:
we manually close Adobe Reader
Adobe Reader times out (after several minutes).
We also can batch print PDF documents directly from the solution using an old version of jPedal, however, these print reduced size, and we cannot figure out how to adjust the print scale.
Would someone be kind enough to provide direction and, perhaps, a code example?
I downloaded the .jar file, put it into beans directory and tried.
I use the same code that you write in the last reply.
I send the output to my printer, I saw a new line in the printer queue but only for a second. then disappear and the printer doesn’t print.
What’s the error in your opinion?
I use servoy 5.2.15.
In the _file_name variable I set the full path of the pdf file. If I set only the name I give an error.
Is it correct?
Thank you very much.
Bye
Roberto
Yes, correct, _file_name is full path to the pdf-file. Servoy 5.2.x should be okay, we are using 5.2.16. If there appears a line in the printer queue it looks like the file is delivered to the printer.
The printer has to be able to handle pdf-documents, maybe that’s the problem. Or maybe the file is not a (correct) pdf file.
The file is a correct pdf file ( I tried with different files ).
What does it mean “The printer has to be able to handle pdf-documents”?
If I open the pdf file and push the print button of Acrobat Reader I print correctly the file.
Using your code example and the Apache PDFBox jar, I am able to print PDF documents, but there are a couple of issues:
Printing is slow! It takes approximately 40 seconds to print each PDF document.
The resulting printout does not represent the PDF document as viewed in Adobe Reader. For example, the summary at the bottom of the document prints several inches up from the bottom thereby over-writing a portion of the printout.
Like jPedal, the printed PDF document is reduced in size (about 80%).
I suspect the slow printing has something to do with the document rendering process in PDFBox and that there is nothing I can do to speed this up. By comparison, when I print using Adobe Reader, the document starts printing in about 10 seconds. Does this observation match your own experience?
I looked at the on-line PDFBox documentation under PDDocument and could not find anything regarding print scaling. Do your documents print at 80% as well? If not, how did you get around this? I was looking for a ‘FIt to Page’ setting but could find none. Again, by comparison, Adobe Reader prints the same PDF document full page with no reduction in size.
Any further help you may provide will be greatly appreciated.
Adding the following line of code (after the document has printed) helps to speed things up:
_document.close()
I still do not know how to scale the PDF document. However, I did discovered that my printer default paper setting was set to size ‘B4’. Changing the default size to ‘letter’ results in the PDF document being printed full page.
This had no effect on jPedal which is still printing at a scale of approximately 80%.
You are right, I omitted that. The example code came from a try block, _document.close() was in the finally block.
I am not experiencing these problems of not printing (Roberto) or not printing exactly the same as Acrobat Reader (Kim), so I’m afraid I cannot help you with that.