Which free Java library can I use to generate PDFs in Java? - java

I have a need to generate some PDF documents through Java .. Which API or library, etc, can I use to do this in the most effective way ?
EDIT: Added requirements:
I'll be using this for a commercial application, so I'd like to work with a library which is free to use for commercial applications as well ..
Secondly, my work will be like this: I have a pre-defined PDF file which has blank text fields in it. This would be my 'template file', and can be generated manually. Then, within my program, I would then take this file, put data into the text fields and generate new PDFs. And this would be done repeatedly.
So for the above added requirements, what would be the best library for me now ? iText does seem appealing, but it seems I would have to pay for it if I wanted to use it in a commercial app, which I'd like to avoid ..

http://itextpdf.com/download.php

Check out iText:
http://itextpdf.com/

I am using Apache PDFBox to generate PDF in java
Reference : https://pdfbox.apache.org/

iText is probably the best, but if you cannot live with their license there is also Apache PDFBox.

If you are creating your PDF templates yourself, then you might want to look at Docmosis - it lets you create templates in Word or OpenOffice with fields that you replace when you render documents. There is a free version you can distribute with your application if your document volumes are low.

Related

library to bring a pdf to code

I have the need to create some pdf through java code, pdf templates are fixed and are very complex too. Each pdf represents a module and I have to fill it with informations I get from other sources in my application and finally create the complete pdf.
So, is there a library which, given a pdf, scans it and creats some java code which will eventually create it back? This way once I get the pdf template in java code I just have to edit it adding my informations and create it back.
You can check these 2 link it's have all information regarding PDF CRUD operation.
How to read PDF files using Java?
http://mrbool.com/how-to-create-write-and-read-pdf-files-using-pdfone-and-java/27058
I have used with success iText http://itextpdf.com/ for various tasks involving creating, parsing and modifying pdf files. Please not that this one is not free for commercial use and the pricing isn't cheap either.
However, your question is a possible duplicate of the folowing one, so be sure to check the answers there:
https://stackoverflow.com/questions/6118635/what-is-the-best-pdf-open-source-library-for-java
itext is one of best approach for your need..
itext API'S

Design PDF template and populate data at runtime using java,xml etc

well i have been looking for a java based PDF solutions...we dont have a clean way i guess-still.. all solutions are primitive and kind of workarounds... No easy solution for this requirement -
1. Designing a PDF template using a IDE (eg. Livecycle designer ..which is not free)
2. Then at runtime using java, populate data into this PDF template...either using xml or other datasources...
such a simple requirement and NONE has a good "open-source and free" solution yet ! Is anyone aware of any ? I have been searching for since 3-4 years now..for a clean way out...
Eclipse BIRT comes close.. but does not handle Barcode elements ..OOB.
Jasper - ireport is also good but that tool does not have a table concept and is kind of annoying ! Also barcode support is not good.
XSL-FO has not free IDE for design .
Looking for a better answer .. got one ?
If it's a "simple requirement", you could create a report designer around iText and release it as FOSS yourself.
What are your key requirements? Does your input have to be a PDF? If so, you'll be probably working uphill for a long time still. Obviously you want to inject data and output a PDF.
If your templates can be something other than PDF, you could try using the OpenOffice API to get OpenOffice to do manipulate documents and produce a PDF. JODReports or Docmosis would be better ways of interacting with OpenOffice and Docmosis allows you to treat documents (doc and odt) as templates.
You can create a PDF file with AcroField through iText API AcroField values can be populated.
Note: Using OpenOffice you can create PDF document with FormFields.
http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/
You could use OpenOffice's UNO API. It looks rather heavyweight but at least you get something full-featured.
Have a look at XDocReport. You create your templates in word .docx or OpenOffice .odt files, then turn them into populated PDF files with Java code.

Creating PDF for Java applications

How to create pdf with complex design views in Java?I have tried it using jasper reports.Is there Any Ideas for creating PDF for Income tax forms?.
A commonly used Java API to create PDF files is iText. Give it a look. API documentation can be found here, code examples can be found here, a tutorial can be found here.
A good but less widely known Java API is OOo API wherein you can create any OOo document to your taste and finally export to PDF.
Have you taken a look at the Apache PDFBox project. I believe you can create PDFs using this library, although it is more commonly used in Lucene to convert PDFs to text to allow indexing.
You could also try Docmosis or JODConverter to do the conversion as long as you can install OpenOffice somewhere. They work on many platforms and can be Java controlled and will save you the hassle of learning the OOo UNO API.
Design your complex PDF Form with the appropriate tools, something like Acrobat Professional. Then from your Java code, you generate an FDF file (Form Data Format) and let the PDF Reader do the merging or you do it from the server-side and stream back the result.
Possible solutions to process FDF are Adobe Java FDF Toolkit or Apache PDFBox.
one approach that requires very little programming is converting your Java object to XML using the Java Binding API for XML (JABX) and then use apache FOP (XSL-FO) to create the PDF from XML. The adavantage of this approach is that is almost 100% declarative, .i.e no programming involved other than executing jabx and apache fop. If you want a tool to create the XSL-FO template, look at J4L FO Designer
You can try ITextPDF.jar Add this jar to your application and please go through the examples to know more about the tags and design procedure used for creating a PDF Document. Check this link for a simple exmaple http://itextpdf.com/examples/iia.php?id=12

Generating PDF files dynamically in servlets?

Is there any way to create PDF dynamically against receiving texts and images?
You can use the iText library.
If you're generating reports then JasperReports can generate PDF output.
iText and JasperReports are great to create pdf reports via Java.
With iReport you can easily create the jasper files needed for this. Very easy to use tool and helped me a lot when I needed to create some pdf reports.
We use Flying Saucer.
There are several libraries for working with PDF in Java, for example iText and Apache PDFBox.
There's a ton of ways to generate PDFs on the fly.
In Java, you can use the iText library. If you wanted to use Jython, you could use reStructuredText and possibly rst2pdf. Or you could just generate LaTeX files on the fly and make a system call to LaTeX.
A bit late but maybe useful to other searchers. Docmosis can populate templates and produce documents on the fly. Assuming you mean you need to include images and text, Docmosis can populate these on the fly from Java objects, text/image files, database queries etc. Java and Openoffice are required server-side.
I work with Apache FOP and it works amazingly well. It's well supported and it's based on the XSL-FO standard.
If you're doing reports based on for example SQL queries then iReport is a good choice although it's sometimes a bit heavyweight. On the other hand if you're going to produce something that's more about presentation and design, like a product sheet or a brochure then my experience is that it's alot easier to first generate html and css and then use it to generate a PDF.

Create Word/RTF file with table of contents from Java

I want to create a Word or RTF file with a table of contents (with links to each section) from Java. From my understanding, iText & Apache POI do not support generating a table of contents. Some clients of the app still use older versions of Word, so I need a library that supports the older Word doc format. Does anyone know how I can do this?
Thanks,
Glen
Look into the Java API for OpenOffice. It will do what you want.
Late, but possibly helpful to others. Docmosis is a good option here. It works over the OpenOffice API but you don't have to spend the time learning that API. It provides template population and manipulation, a range of data source options and all the input and output options of OpenOffice. Specifically, it also updates the TOC and indexes at the final stages of document rendering.

Categories