Package com.itextpdf.forms
Class PdfPageFormCopier
java.lang.Object
com.itextpdf.forms.PdfPageFormCopier
- All Implemented Interfaces:
IPdfPageExtraCopier
,IPdfPageFormCopier
A sample implementation of the {#link IPdfPageExtraCopier} interface which
copies only AcroForm fields to a new page.
NOTE: While it's absolutely not necessary to use the same PdfPageFormCopier instance for copying operations, it is still worth to know that PdfPageFormCopier uses some caching logic which can potentially improve performance in case of the reusing of the same instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PdfDocument
private PdfDocument
private PdfAcroForm
private PdfAcroForm
private static org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies a page.private void
copyField
(Map<String, PdfFormField> fieldsFrom, Map<String, PdfFormField> fieldsTo, PdfAnnotation currentAnnot) private void
copyParentFormField
(Map<String, PdfFormField> fieldsTo, PdfAnnotation annot, PdfFormField parentField) private PdfFormField
createParentFieldCopy
(PdfDictionary fieldDict, PdfDocument pdfDoc) private static PdfFormField
getParentField
(PdfDictionary parent, PdfDocument pdfDoc) private AbstractPdfFormField
makeFormField
(PdfObject fieldDict) void
recreateAcroformToProcessCopiedFields
(PdfDocument documentTo) Create Acroform from its PDF object to process form field objects added to the Acroform during copying.
-
Field Details
-
formFrom
-
formTo
-
documentFrom
-
documentTo
-
collectedFieldObjects
-
logger
private static org.slf4j.Logger logger
-
-
Constructor Details
-
PdfPageFormCopier
public PdfPageFormCopier()
-
-
Method Details
-
copy
Description copied from interface:IPdfPageExtraCopier
Copies a page. The new page must already be created before calling this, either in a newPdfDocument
or in the samePdfDocument
as the old page.- Specified by:
copy
in interfaceIPdfPageExtraCopier
- Parameters:
fromPage
- the source pagetoPage
- the target page in a target document
-
recreateAcroformToProcessCopiedFields
Description copied from interface:IPdfPageFormCopier
Create Acroform from its PDF object to process form field objects added to the Acroform during copying.All pages must already be copied to the target document before calling this. So fields with the same names will be merged and target document tag structure will be correct.
- Specified by:
recreateAcroformToProcessCopiedFields
in interfaceIPdfPageFormCopier
- Parameters:
documentTo
- the target document.
-
makeFormField
-
copyField
private void copyField(Map<String, PdfFormField> fieldsFrom, Map<String, PdfFormField> fieldsTo, PdfAnnotation currentAnnot) -
copyParentFormField
private void copyParentFormField(Map<String, PdfFormField> fieldsTo, PdfAnnotation annot, PdfFormField parentField) -
getParentField
-
createParentFieldCopy
-