Skip to content

Commit

Permalink
QPDFAcroFormDocumentHelper: add missing analyze calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkenbilt committed Mar 4, 2021
1 parent 0b77f2c commit cb6e531
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
Binary file modified examples/qtest/overlay-page/annotations-out.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion include/qpdf/QPDFAcroFormDocumentHelper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
// done through setFormFieldName() above.
QPDF_DLL
std::set<QPDFObjGen>
getFieldsWithQualifiedName(std::string const& name) const;
getFieldsWithQualifiedName(std::string const& name);

// Return the annotations associated with a terminal field. Note
// that in the case of a field having a single annotation, the
Expand Down
9 changes: 8 additions & 1 deletion libqpdf/QPDFAcroFormDocumentHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ QPDFAcroFormDocumentHelper::QPDFAcroFormDocumentHelper(QPDF& qpdf) :
QPDFDocumentHelper(qpdf),
m(new Members())
{
// We have to analyze up front. Otherwise, when we are adding
// annotations and fields, we are in a temporarily unstable
// configuration where some widget annotations are not reachable.
analyze();
}

void
Expand Down Expand Up @@ -68,6 +72,7 @@ void
QPDFAcroFormDocumentHelper::addAndRenameFormFields(
std::vector<QPDFObjectHandle> fields)
{
analyze();
std::map<std::string, std::string> renames;
std::list<QPDFObjectHandle> queue;
queue.insert(queue.begin(), fields.begin(), fields.end());
Expand Down Expand Up @@ -214,8 +219,9 @@ QPDFAcroFormDocumentHelper::getFormFields()

std::set<QPDFObjGen>
QPDFAcroFormDocumentHelper::getFieldsWithQualifiedName(
std::string const& name) const
std::string const& name)
{
analyze();
// Keep from creating an empty entry
std::set<QPDFObjGen> result;
auto iter = this->m->name_to_fields.find(name);
Expand Down Expand Up @@ -248,6 +254,7 @@ QPDFAcroFormDocumentHelper::getWidgetAnnotationsForPage(QPDFPageObjectHelper h)
std::vector<QPDFFormFieldObjectHelper>
QPDFAcroFormDocumentHelper::getFormFieldsForPage(QPDFPageObjectHelper ph)
{
analyze();
std::set<QPDFObjGen> added;
std::vector<QPDFFormFieldObjectHelper> result;
auto widget_annotations = getWidgetAnnotationsForPage(ph);
Expand Down
Binary file modified qpdf/qtest/qpdf/field-parse-errors-out.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion qpdf/qtest/qpdf/form-form-bad-fields-array.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
iterating over form fields
WARNING: form-bad-fields-array.pdf, object 1 0 at offset 50: /Fields key of /AcroForm dictionary is not an array; ignoring
WARNING: form-bad-fields-array.pdf, object 4 0 at offset 615: this widget annotation is not reachable from /AcroForm in the document catalog
WARNING: form-bad-fields-array.pdf, object 16 0 at offset 3419: this widget annotation is not reachable from /AcroForm in the document catalog
Expand All @@ -11,6 +10,7 @@ WARNING: form-bad-fields-array.pdf, object 32 0 at offset 5893: this widget anno
WARNING: form-bad-fields-array.pdf, object 33 0 at offset 6251: this widget annotation is not reachable from /AcroForm in the document catalog
WARNING: form-bad-fields-array.pdf, object 34 0 at offset 6607: this widget annotation is not reachable from /AcroForm in the document catalog
WARNING: form-bad-fields-array.pdf, object 10 0 at offset 2311: this widget annotation is not reachable from /AcroForm in the document catalog
iterating over form fields
Field: 4 0 R
Parent: none
Fully qualified name: Text Box 1
Expand Down
2 changes: 1 addition & 1 deletion qpdf/qtest/qpdf/form-form-errors.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
iterating over form fields
WARNING: form-errors.pdf, object 4 0 at offset 625: loop detected while traversing /AcroForm
WARNING: form-errors.pdf, object 5 0 at offset 993: encountered a direct object as a field or annotation while traversing /AcroForm; ignoring field or annotation
WARNING: form-errors.pdf, object 15 0 at offset 3452: encountered a non-dictionary as a field or annotation while traversing /AcroForm; ignoring field or annotation
WARNING: form-errors.pdf, object 16 0 at offset 3475: this widget annotation is not reachable from /AcroForm in the document catalog
WARNING: form-errors.pdf, object 32 0 at offset 5974: this widget annotation is not reachable from /AcroForm in the document catalog
iterating over form fields
Field: 4 0 R
Parent: none
Fully qualified name: Text Box 1
Expand Down
Binary file modified qpdf/qtest/qpdf/overlay-copy-annotations.pdf
Binary file not shown.

0 comments on commit cb6e531

Please sign in to comment.