From 1f35ec9988eaf1ad3705655c434701d175c5b49f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 22 Feb 2021 17:44:13 -0500 Subject: Add methods for copying form fields --- include/qpdf/QPDFAcroFormDocumentHelper.hh | 12 ++++++++++++ include/qpdf/QPDFFormFieldObjectHelper.hh | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'include') diff --git a/include/qpdf/QPDFAcroFormDocumentHelper.hh b/include/qpdf/QPDFAcroFormDocumentHelper.hh index eb9da5ad..fd28a579 100644 --- a/include/qpdf/QPDFAcroFormDocumentHelper.hh +++ b/include/qpdf/QPDFAcroFormDocumentHelper.hh @@ -140,6 +140,11 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper std::vector getWidgetAnnotationsForPage(QPDFPageObjectHelper); + // Return form fields for a page. + QPDF_DLL + std::vector + getFormFieldsForPage(QPDFPageObjectHelper); + // Return the terminal field that is associated with this // annotation. If the annotation dictionary is merged with the // field dictionary, the underlying object will be the same, but @@ -204,6 +209,13 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper QPDF* from_qpdf = nullptr, QPDFAcroFormDocumentHelper* from_afdh = nullptr); + // Copy form fields from a page in a different QPDF object to this + // QPDF. + QPDF_DLL + void copyFieldsFromForeignPage( + QPDFPageObjectHelper foreign_page, + QPDFAcroFormDocumentHelper& foreign_afdh); + private: void analyze(); void traverseField(QPDFObjectHandle field, diff --git a/include/qpdf/QPDFFormFieldObjectHelper.hh b/include/qpdf/QPDFFormFieldObjectHelper.hh index b9168d22..edb93df8 100644 --- a/include/qpdf/QPDFFormFieldObjectHelper.hh +++ b/include/qpdf/QPDFFormFieldObjectHelper.hh @@ -54,6 +54,13 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper QPDF_DLL QPDFFormFieldObjectHelper getParent(); + // Return the top-level field for this field. Typically this will + // be the field itself or its parent. If is_different is provided, + // it is set to true if the top-level field is different from the + // field itself; otherwise it is set to false. + QPDF_DLL + QPDFFormFieldObjectHelper getTopLevelField(bool* is_different = nullptr); + // Get a field value, possibly inheriting the value from an // ancestor node. QPDF_DLL -- cgit v1.2.3-54-g00ecf