public class PDFFields extends Object
PDFFields
class provides methods to work with interactive PDF forms - also called acroforms. Modifier and Type | Class and Description |
---|---|
static class |
PDFFields.KeyInfoFields
This is the Main-Class for the jPDFFields.jar that can generate server
key requests, validate a key, and display server information.
|
Constructor and Description |
---|
PDFFields(InputStream inStream,
IPassword password)
Loads a PDF document from an InputStream.
|
PDFFields(String fileName,
IPassword password)
Loads a PDF document from a file.
|
PDFFields(URL url,
IPassword password)
Loads a PDF document from a URL.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close / release all resources held by this document.
|
boolean |
containsJavaScript()
Returns true when the PDF document contains javascript.
|
void |
exportAsFDF(OutputStream outStream,
String pathToPDFFile,
boolean exportEmptyFields)
Export AcroForm field data to an output stream in FDF format.
|
void |
exportAsFDF(String fileName,
boolean exportEmptyFields)
Exports AcroForm field data to a file in FDF format.
|
void |
exportAsXDP(OutputStream outStream,
String pathToPDFFile,
boolean exportEmptyFields)
Export XFA field data to an output stream in XDP format.
|
void |
exportAsXDP(String fileName,
boolean exportEmptyFields)
Exports XFA field data to a file in XDP format.
|
void |
exportAsXFDF(OutputStream outStream,
String pathToPDFFile,
boolean exportEmptyFields)
Export AcroForm field data to an output stream in XFDF format.
|
void |
exportAsXFDF(String fileName,
boolean exportEmptyFields)
Exports AcroForm field data to a file in XML format.
|
void |
flattenFields(boolean paintButtons,
boolean paintNonPrintableFields)
Flattens the form fields in the current PDF document.
|
void |
flattenFields(boolean paintButtons,
boolean paintOnlyImageButtons,
boolean paintNonPrintableFields)
Flattens the form fields in the current PDF document.
|
DocumentInfo |
getDocumentInfo()
Returns a DocumentInfo object containing the information
section of a PDF document (author, title, etc.)
|
FormField |
getField(String fieldName)
Gets a field by name.
|
Vector<FormField> |
getFieldList()
Gets the list of fields in this AcroForm.
|
static String |
getVersion()
Returns version string for jPDFFields.
|
boolean |
hasXFA()
Returns true if this AcroForm has Adobe XML Forms Architecture (XFA) data.
|
void |
importFDF(InputStream inStream)
Import AcroForm field data from an input stream in FDF format.
|
void |
importFDF(String fileName)
Import AcroForm field data from a file in FDF Format.
|
void |
importXDP(InputStream inStream)
Import XFA field data from an input stream in XDP format.
|
void |
importXDP(String fileName)
Import XFA field data from a file in XDP Format.
|
void |
importXFDF(InputStream inStream)
Import AcroForm field data from an input stream in XML format.
|
void |
importXFDF(String fileName)
Import AcroForm fields data from a file in XML Format.
|
boolean |
isXFADynamic()
Returns true if this AcroForm has Adobe XML Forms Architecture (XFA) data, and it is a Dynamic Form.
|
boolean |
isXFAStatic()
Returns true if this AcroForm has Adobe XML Forms Architecture (XFA) data, and it is a Static Form.
|
static void |
loadLicense(InputStream licenseStream)
Method to load a license file from an inputstream.
|
static void |
loadLicense(String licenseFile)
Method to load a license file.
|
void |
resetFields()
Reset fields values to their default value.
|
void |
saveDocument(OutputStream outStream)
Saves this document to an output stream.
|
void |
saveDocument(String fileName)
Saves this document to a file.
|
static boolean |
setAppletKey(String key,
Applet applet)
Method to unlock the production version of the library.
|
static boolean |
setKey(String key)
Method to unlock the production version of the library.
|
boolean |
usePermissionsPassword(String ownerPassword)
Tells the PDFFields object that the permissions password is known, so all
permissions are granted.
|
public PDFFields(InputStream inStream, IPassword password) throws PDFException
inStream
- InputStream to read the PDF document.password
- An object that provides passwords to open the document, leave null if not needed.
When working with documents that have no passwords, the host application should pass null for the
value of this parameter. When documents are known to have passwords, the host application should
pass an instance of the PDFPassword
class that can hold a single
password or a list of passwords.PDFException
public PDFFields(String fileName, IPassword password) throws PDFException
fileName
- Name of the PDF file.password
- An object that provides passwords to open the document, leave null if not needed.
When working with documents that have no passwords, the host application should pass null for the
value of this parameter. When documents are known to have passwords, the host application should
pass an instance of the PDFPassword
class that can hold a single
password or a list of passwords.PDFException
public PDFFields(URL url, IPassword password) throws PDFException
url
- Location of the PDF document.password
- An object that provides passwords to open the document, leave null if not needed.
When working with documents that have no passwords, the host application should pass null for the
value of this parameter. When documents are known to have passwords, the host application should
pass an instance of the PDFPassword
class that can hold a single
password or a list of passwords.PDFException
public void close()
public DocumentInfo getDocumentInfo()
public static String getVersion()
public void exportAsFDF(OutputStream outStream, String pathToPDFFile, boolean exportEmptyFields) throws PDFException, IOException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the fdf file to the pdf file name. This parameter can be left null.
This parameter is used to fill the pdf file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileNa
The file entry is used when you open an fdf file to be able to locate the corresponding pdf file.exportEmptyFields
- flag to indicate whether empty or null fields should be exported.
Example of pathToPDFFile ../qoppa/mydirPDFException
IOException
public void exportAsFDF(String fileName, boolean exportEmptyFields) throws PDFException, IOException
fileName
- The name of the file to export the data to.exportEmptyFields
- flag to indicate whether empty or null fields should be exported.PDFException
IOException
public void exportAsXFDF(OutputStream outStream, String pathToPDFFile, boolean exportEmptyFields) throws PDFException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the fdf file to the pdf file name. This parameter can be left null.
This parameter is used to fill the pdf file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileNa
The file entry is used when you open an fdf file to be able to locate the corresponding pdf file.
Example of pathToPDFFile ../qoppa/mydirexportEmptyFields
- flag to indicate whether empty or null fields should be exported.PDFException
public void exportAsXFDF(String fileName, boolean exportEmptyFields) throws PDFException
fileName
- The name of the file to export the data to.exportEmptyFields
- flag to indicate whether empty or null fields should be exported.IOException
PDFException
public void exportAsXDP(String fileName, boolean exportEmptyFields) throws IOException, PDFException
fileName
- The name of the file to export the data to.exportEmptyFields
- flag to indicate whether empty or null fields should be exported.IOException
- If there are any errors opening or writing to the file.PDFException
public void exportAsXDP(OutputStream outStream, String pathToPDFFile, boolean exportEmptyFields) throws IOException, PDFException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the xdp file to the pdf file name. This parameter can be left null.
This parameter is used to fill the pdf file name reference in the XDP file, the file entry will be set to pathToPDFFile + fileNameexportEmptyFields
- flag to indicate whether empty or null fields should be exported.
IOException
- If there are any errors writing to the output stream.PDFException
public void flattenFields(boolean paintButtons, boolean paintNonPrintableFields) throws PDFException
paintButtons
- Flag to indicate whether push buttons should be painted or not.paintNonPrintableFields
- Flag to indicate whether non-printable fields should be painted or not.PDFException
public void flattenFields(boolean paintButtons, boolean paintOnlyImageButtons, boolean paintNonPrintableFields) throws PDFException
paintButtons
- Flag to indicate whether push buttons should be painted or not.paintOnlyImageButtons
- Flag to indicate that push buttons should only be painted if they have an image (only matters if paintButtons is true)paintNonPrintableFields
- Flag to indicate whether non-printable fields should be painted or not.PDFException
public Vector<FormField> getFieldList()
public FormField getField(String fieldName)
fieldName
- The name of a field in hierarchical form.public void importFDF(InputStream inStream) throws PDFException
inStream
- The input stream in FDF format to read the data from.PDFException
public void importFDF(String fileName) throws PDFException
fileName
- The name of the FDF file to import the data from.PDFException
public void importXFDF(InputStream inStream) throws PDFException
inStream
- The input stream in XML format to read the data from.PDFException
public void importXDP(String fileName) throws PDFException, IOException
fileName
- The name of the XDP file to import the data from.PDFException,
- IOExceptionPDFException
IOException
public void importXDP(InputStream inStream) throws PDFException, IOException
inStream
- The input stream in XDP format to read the data from.
throws PDFException, IOExceptionPDFException
IOException
public void importXFDF(String fileName) throws PDFException
fileName
- The name of the XML file to import the data from.PDFException
public void resetFields() throws PDFException
PDFException
public void saveDocument(String fileName) throws IOException, PDFException
fileName
- Name of the file to save the document.IOException
PDFException
public void saveDocument(OutputStream outStream) throws IOException, PDFException
outStream
- OutputStream where the document will be written to.IOException
PDFException
public static boolean setAppletKey(String key, Applet applet)
key
- Production key.public static boolean setKey(String key)
key
- Production key.public static void loadLicense(InputStream licenseStream) throws LicenseException
licenseStream
- The input stream for the license file contents.LicenseException
- If there are any problems with the license filepublic static void loadLicense(String licenseFile) throws LicenseException, IOException
licenseFile
- The full path to the license file.LicenseException
- If there are any problems with the license fileIOException
public boolean hasXFA()
public boolean isXFAStatic()
public boolean isXFADynamic()
public boolean containsJavaScript()
public boolean usePermissionsPassword(String ownerPassword) throws PDFException
ownerPassword
- The permissions passwordPDFException