Class 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 TypeMethodDescriptionObject[]
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)void
setPassword
(String password) Methods inherited from class org.jpedal.examples.BaseExample
closePDFfile, openPDFFile
-
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
-
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:
filter
- should be a name, reference or nullvalue
- enum defining what values to return- Returns:
- Some examples which all return Object[]
all forms in document
getFormComponentsFromDocument(null, ReturnValues.FORMOBJECTS_FROM_REF);
getFormComponentsFromDocument(null, ReturnValues.FORMOBJECTS_FROM_NAME);
all formNames
getFormComponentsFromDocument(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 PDF
getFormComponentsFromDocument("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 5
getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_REF, 5);
getFormComponentsFromPage(null, ReturnValues.FORMOBJECTS_FROM_NAME, 5);
all formNames
getFormComponentsFromPage(null, ReturnValues.FORM_NAMES, -1);
all FormNames of Forms on page 12
getFormComponentsFromPage(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
-