Package com.itextpdf.forms
Class PdfPageFormCopier
- java.lang.Object
-
- com.itextpdf.forms.PdfPageFormCopier
-
- All Implemented Interfaces:
IPdfPageExtraCopier,IPdfPageFormCopier
public class PdfPageFormCopier extends java.lang.Object implements 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
Fields Modifier and Type Field Description private java.util.Set<PdfObject>collectedFieldObjectsprivate PdfDocumentdocumentFromprivate PdfDocumentdocumentToprivate PdfAcroFormformFromprivate PdfAcroFormformToprivate static org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description PdfPageFormCopier()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(PdfPage fromPage, PdfPage toPage)Copies a page.private voidcopyField(java.util.Map<java.lang.String,PdfFormField> fieldsFrom, java.util.Map<java.lang.String,PdfFormField> fieldsTo, PdfAnnotation currentAnnot)private voidcopyParentFormField(java.util.Map<java.lang.String,PdfFormField> fieldsTo, PdfAnnotation annot, PdfFormField parentField)private PdfFormFieldcreateParentFieldCopy(PdfDictionary fieldDict, PdfDocument pdfDoc)private static PdfFormFieldgetParentField(PdfDictionary parent, PdfDocument pdfDoc)private AbstractPdfFormFieldmakeFormField(PdfObject fieldDict)voidrecreateAcroformToProcessCopiedFields(PdfDocument documentTo)Create Acroform from its PDF object to process form field objects added to the Acroform during copying.
-
-
-
Field Detail
-
formFrom
private PdfAcroForm formFrom
-
formTo
private PdfAcroForm formTo
-
documentFrom
private PdfDocument documentFrom
-
documentTo
private PdfDocument documentTo
-
collectedFieldObjects
private final java.util.Set<PdfObject> collectedFieldObjects
-
logger
private static org.slf4j.Logger logger
-
-
Method Detail
-
copy
public void copy(PdfPage fromPage, PdfPage toPage)
Description copied from interface:IPdfPageExtraCopierCopies a page. The new page must already be created before calling this, either in a newPdfDocumentor in the samePdfDocumentas the old page.- Specified by:
copyin interfaceIPdfPageExtraCopier- Parameters:
fromPage- the source pagetoPage- the target page in a target document
-
recreateAcroformToProcessCopiedFields
public void recreateAcroformToProcessCopiedFields(PdfDocument documentTo)
Description copied from interface:IPdfPageFormCopierCreate 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:
recreateAcroformToProcessCopiedFieldsin interfaceIPdfPageFormCopier- Parameters:
documentTo- the target document.
-
makeFormField
private AbstractPdfFormField makeFormField(PdfObject fieldDict)
-
copyField
private void copyField(java.util.Map<java.lang.String,PdfFormField> fieldsFrom, java.util.Map<java.lang.String,PdfFormField> fieldsTo, PdfAnnotation currentAnnot)
-
copyParentFormField
private void copyParentFormField(java.util.Map<java.lang.String,PdfFormField> fieldsTo, PdfAnnotation annot, PdfFormField parentField)
-
getParentField
private static PdfFormField getParentField(PdfDictionary parent, PdfDocument pdfDoc)
-
createParentFieldCopy
private PdfFormField createParentFieldCopy(PdfDictionary fieldDict, PdfDocument pdfDoc)
-
-