Package org.jpedal.examples.acroform
Class PdfFormUtilities
java.lang.Object
org.jpedal.examples.acroform.PdfFormUtilities
PdfFormsUtilities
General XFA, Annotations and AcroForm features provided by JPedal grouped into one class to provide simple API
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
ensure PDF file is closed once no longer needed and all resources releasedObject[]
getFormComponentsFromDocument
(String filter, org.jpedal.objects.acroforms.ReturnValues value) access the PDF FormObjects (if present) from the open PDF file and return Object values according to ReturnValues.Object[]
getFormComponentsFromPage
(String filter, org.jpedal.objects.acroforms.ReturnValues value, int page) access the PDF FormObjects (if present) from the page of the open PDF file and return Object values according to ReturnValues.int
number of pages in PDF file (starting at 1)byte[]
getRawXFAData
(int dataType) access XFA raw data(only works in XFA releases)boolean
routine to open the PDF File so we can accessvoid
setPassword
(String password)
-
Constructor Details
-
PdfFormUtilities
-
PdfFormUtilities
public PdfFormUtilities(byte[] byteArray)
-
-
Method Details
-
setPassword
- Parameters:
password
- the USER or OWNER password for the PDF file
-
getPageCount
public int getPageCount()number of pages in PDF file (starting at 1)- Returns:
- page count
-
openPDFFile
routine to open the PDF File so we can access- Returns:
- true if successful
- Throws:
PdfException
- if problem with opening a PDF file
-
closePDFfile
public void closePDFfile()ensure PDF file is closed once no longer needed and all resources released -
getFormComponentsFromDocument
public Object[] getFormComponentsFromDocument(String filter, org.jpedal.objects.acroforms.ReturnValues value) throws PdfException access the PDF FormObjects (if present) from the open PDF file and return Object values according to ReturnValues.- Parameters:
value
- enum defining what values to returnfilter
- should be a name, reference or null- Returns:
Some examples which all return Object[] all forms in document
getFormComponentsFromDocument(null, ReturnValues.FORMOBJECTS_FROM_REF);
getFormComponentsFromDocument(null, ReturnValues.FORMOBJECTS_FROM_NAME);
all formNamesgetFormComponentsFromDocument(null, ReturnValues.FORM_NAMES);
all forms in document called Mabel (zero values returned if no match)getFormComponentsFromDocument("Mabel", ReturnValues.FORMOBJECTS_FROM_NAME);
a form with PDF Reference 25 0 R (zero values returned if no match)getFormComponentsFromDocument("25 0 R", ReturnValues.FORMOBJECTS_FROM_REF);
any embedded file objects in PDFgetFormComponentsFromDocument("25 0 R", ReturnValues.EMBEDDED_FILES);
if you need direct access to the GUI components, you can use (this will also trigger resolving these objects if Swing so we recommend you work with FormObjects unless you explicitly need this)getFormComponentsFromDocument(null, ReturnValues.GUI_FORMS_FROM_NAME);
- Throws:
PdfException
- if error in reading pdf file
-
getFormComponentsFromPage
public Object[] getFormComponentsFromPage(String filter, org.jpedal.objects.acroforms.ReturnValues value, int page) throws PdfException access the PDF FormObjects (if present) from the page of the open PDF file and return Object values according to ReturnValues.- Parameters:
filter
- should be a name, reference or nullvalue
- should be an enum GUI_FORMS_FROM_NAME, FORM_NAMES, FORMOBJECTS_FROM_NAME,FORMOBJECTS_FROM_REFpage
- will only return forms assigned to this page, or whole document if -1- Returns:
- *
Some examples which all return Object[] all forms in document
getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_REF, -1);
getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_NAME, -1);
all forms on page 5getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_REF, 5);
getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_NAME, 5);
all formNamesgetFormComponentsFromPage(null, ReturnValues.FORM_NAMES, -1);
all FormNames of Forms on page 12getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_REF, 12);
all forms in document called Mabel (zero values returned if no match)getFormComponentsFromPage("Mabel", ReturnValues.FORMOBJECTS_FROM_NAME, -1);
all forms on page 5 called Mabel (zero values returned if no match)getFormComponentsFromPage("Mabel", ReturnValues.FORMOBJECTS_FROM_NAME, 5);
form with PDF Reference 25 0 R (zero values returned if no match)getFormComponentsFromPage("25 0 R", ReturnValues.FORMOBJECTS_FROM_REF, -1);
form with PDF Reference 25 0 R on page 5 (zero values returned if no match)getFormComponentsFromPage("25 0 R", ReturnValues.FORMOBJECTS_FROM_REF, 5);
if you need direct access to the GUI components, you can use (this will also trigger resolving these objects if Swing so we recommend you work with FormObjects unless you explicitly need this)getFormComponentsFromPage(null, ReturnValues.GUI_FORMS_FROM_NAME, -1);
getFormComponentsFromPage(null, ReturnValues.GUI_FORMS_FROM_NAME, 5);
- Throws:
PdfException
- if error in reading xfa data from pdf file
-
getRawXFAData
access XFA raw data(only works in XFA releases)- Parameters:
dataType
- PdfDictionary.XFA_CONFIG, PdfDictionary.XFA_DATASET,PdfDictionary.XFA_TEMPLATE- Returns:
- null or byte[]
- Throws:
PdfException
- if error in reading xfa data from pdf file
-