Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create PDF with Java [duplicate]

Tags:

java

export

pdf

Possible Duplicate:
PDF Generation Library for Java

I'm working on an invoice program for a local accounting company. What is a good way to create a PDF file with Java? Any good library? I'm totally new to PDF export (On any language).

like image 676
hogni89 Avatar asked Sep 08 '11 21:09

hogni89


People also ask

Which is better iText or PDFBox?

One major difference is that PDFBox always processes text glyph by glyph while iText normally processes it chunk (i.e. single string parameter of text drawing operation) by chunk; that reduces the required resources in iText quite a lot.

Can you duplicate a PDF page?

You can also choose where to place the duplicate in your document. To duplicate a page: Go to the Insert tab and click the Insert button in PAGE feature. In the pop-up menu, choose Duplicate.


2 Answers

I prefer outputting my data into XML (using Castor, XStream or JAXB), then transforming it using a XSLT stylesheet into XSL-FO and render that with Apache FOP into PDF. Worked so far for 10-page reports and 400-page manuals. I found this more flexible and stylable than generating PDFs in code using iText.

like image 97
Philipp Reichart Avatar answered Sep 22 '22 13:09

Philipp Reichart


Following are few libraries to create PDF with Java:

  1. iText
  2. Apache PDFBox
  3. BFO

I have used iText for genarating PDF's with a little bit of pain in the past.

Or you can try using FOP: FOP is an XSL formatter written in Java. It is used in conjunction with an XSLT transformation engine to format XML documents into PDF.

like image 22
Ritesh Mengji Avatar answered Sep 22 '22 13:09

Ritesh Mengji