Commit ea58680eb07d1551d1f179532a3880e2d89f6c69

Authored by Jay Berkenbilt
1 parent bb313729

Mention appearances in pdf-set-form-values example

ChangeLog
1 1 2020-02-22 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Update pdf-set-form-values.cc to use and mention
  4 + generateAppearance, which hadn't been added when the example was
  5 + originally created.
  6 +
3 7 * Detect, warn, and correct the case of /Pages in the document
4 8 catalog incorrectly pointing to a page or intermediate node
5 9 instead of the root of the pages tree. Fixes #398.
... ...
examples/pdf-set-form-values.cc
... ... @@ -73,23 +73,23 @@ int main(int argc, char* argv[])
73 73 annot_iter != annotations.end(); ++annot_iter)
74 74 {
75 75 // For each annotation, find its associated field. If
76   - // it's a text field, set its value. This will
77   - // automatically update the document to indicate that
78   - // appearance streams need to be regenerated. At the
79   - // time of this writing, qpdf doesn't have any helper
80   - // code to assist with appearance stream generation,
81   - // though there's nothing that prevents it from being
82   - // possible.
  76 + // it's a text field, set its value.
83 77 QPDFFormFieldObjectHelper ffh =
84 78 afdh.getFieldForAnnotation(*annot_iter);
85 79 if (ffh.getFieldType() == "/Tx")
86 80 {
87   - // Set the value. This will automatically set
88   - // /NeedAppearances to true. If you don't want to
89   - // do that, pass false as the second argument. For
90   - // details see comments in
91   - // QPDFFormFieldObjectHelper.hh.
92   - ffh.setV(value);
  81 + // Set the value. Passing false as the second
  82 + // value prevents qpdf from setting
  83 + // /NeedAppearances to true (but will not turn it
  84 + // off if it's already on), so we call
  85 + // generateAppearance after setting the value. You
  86 + // may or may not want to do this depending on
  87 + // whether the appearance streams generated by
  88 + // qpdf are good enough for your purposes. For
  89 + // additional details, please see comments in
  90 + // QPDFFormFieldObjectHelper.hh for this method.
  91 + ffh.setV(value, false);
  92 + ffh.generateAppearance(*annot_iter);
93 93 }
94 94 }
95 95 }
... ...
examples/qtest/set-form-values/form-out.pdf
No preview for this file type