by Qoppa Software - Product Type: Component / Java Class
Interact with and manipulate PDF forms. jPDFFields is a Java library that works with interactive PDF forms in both AcroForm and XFA formats. jPDFFields allows your application to get and set field values and can also import and export to FDF, XFDF and XDP formats. Additionally, jPDFFields can also flatten fields in a document. Flattening is the process of merging the fields into the PDF content layer so that the information is retained but as static PDF content. jPDFFields is built on top of Qoppa's proprietary PDF technology so it is 100% Java and does not require any third party software or drivers
jPDFFields Main Features
jPDFFields - Getting Started
The starting point for using jPDFFields is the com.qoppa.pdfFields.PDFFields. This class is used to load documents into an application, work with form fields and then save the document. The class provides three constructors to load PDF files from the file system, a URL or an InputStream. All constructors take an additional parameter, an object that implements IPasswordHandler, that will be queried if the PDF file has requires a password to open. For PDF files that are not encrypted, this second parameter can be null.
jPDFFields - Extracting Data from Fields Programmatically
Once a PDFFields object has been created, the host application simply needs to call the getFields method to get the list of fields in the loaded PDF document. It is then possible to work with each field individually based on its field type to extract information and data.
jPDFFields - Exporting to FDF or XFDF
To export fields data to an FDF or XFDF file (or output stream), simply call the exportAsFDF or exportAsXFDF method in the PDFFields class. Both methods are available with a File argument or a Java OutputStream argument.
jPDFFields - Filling Fields with Data Programmatically
To fill in the fields with data, you can use the getField method to get a field by field name and then use the setValue method to set the data. To set values in combo boxes and list fields, use values from the field's export options and not the display options. To save the pdf document, you need to call the save method.
jPDFFields - Importing Data from FDF or XFDF
To import data into fields from an FDF or XFDF file (or output stream), simply call the importFDF or importXFDF method in the PDFFields class. Both methods are available with a File argument or an Java InputStream argument. If you need to save the pdf document, you need to call the save method explicitly.
jPDFFields - Flattening Fields
To flatten form fields in a PDF form, simply call the flattenFields method in the PDFFields class. This will paint the content of the fields directly into the page and remove the fields themselves from the PDF document. This method takes a boolean as a parameter to indicate whether push buttons should be painted or not. Most of the time, it doesn't make sense to paint a push button once its flattened since it has no action anymore.
jPDFFields - Getting Basic Information about the PDF Document (Title, Author, etc...)
To get basic information about the loaded PDF document, you need to get the DocumentInfo class accessible through PDFFields.getDocumentInfo. From this class, you can get information about the document such as title, author, subject, keywords, etc.
jPDFFields - Distribution and JAR Files
jPDFFields is packaged in a single jar file, jPDFFields.jar that gets installed with the evaluation sample. When distributing an application that contains jPDFFields, the jPDFFields.jar file needs to be distributed along with it and needs to be included in the class path when running the application.