In an earlier post, I presented code to "print" to a PDF file from a Pageable. Since then I have added the ability to concatenate multiple Pageables into a single PDF file, with the option for bookmarks. The previous code was modified and some things renamed.
A small interface, PDFBookmarker, was added.
The previous class, PDFPrinter, was renamed PDFStream (mainly to keep it different). The new class takes an OutputStream in the constructor, since it may be shared across multiple prints.
The key method, which was called printToPdf(), is renamed to the clearer appendToPDF().
A few new methods, such as newPage() and close(), were added, so you can control output in between prints, and at the end.
The two java files are available via Assembla, at http://www.assembla.com/code/hastur/subversion/nodes/trunk/Hastur_J/src/com/flyingspaniel/pdf
This code requires the wonderful iText library, either 2.1.7 or 5. Enjoy!
Friday, June 29, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment