diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-01-04 01:09:00 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-01-04 14:00:19 +0100 |
commit | 158156d5062a5ac335bcfde7893be4671affdc32 (patch) | |
tree | 20d0017133c845a85071473ceefcd2b6e186e472 /include | |
parent | 02281632ccbba3ef00a6968bfd697f4be836d0dd (diff) | |
download | qpdf-158156d5062a5ac335bcfde7893be4671affdc32.tar.zst |
Add basic appearance stream generation
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFAcroFormDocumentHelper.hh | 10 | ||||
-rw-r--r-- | include/qpdf/QPDFFormFieldObjectHelper.hh | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/qpdf/QPDFAcroFormDocumentHelper.hh b/include/qpdf/QPDFAcroFormDocumentHelper.hh index 3a308467..281056b9 100644 --- a/include/qpdf/QPDFAcroFormDocumentHelper.hh +++ b/include/qpdf/QPDFAcroFormDocumentHelper.hh @@ -157,6 +157,16 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper QPDF_DLL void setNeedAppearances(bool); + // If /NeedAppearances is false, do nothing. Otherwise generate + // appearance streams for all widget annotations that need them. + // See comments in QPDFFormFieldObjectHelper.hh for + // generateAppearance for limitations. For checkbox and radio + // button fields, this code ensures that appearance state is + // consistent with the field's value and uses any pre-existing + // appearance streams. + QPDF_DLL + void generateAppearancesIfNeeded(); + private: void analyze(); void traverseField(QPDFObjectHandle field, diff --git a/include/qpdf/QPDFFormFieldObjectHelper.hh b/include/qpdf/QPDFFormFieldObjectHelper.hh index 7ab9a1c0..a03ce555 100644 --- a/include/qpdf/QPDFFormFieldObjectHelper.hh +++ b/include/qpdf/QPDFFormFieldObjectHelper.hh @@ -31,6 +31,8 @@ #include <qpdf/DLL.h> #include <vector> +class QPDFAnnotationObjectHelper; + class QPDFFormFieldObjectHelper: public QPDFObjectHelper { public: @@ -179,9 +181,21 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper QPDF_DLL void setV(std::string const& utf8_value, bool need_appearances = true); + // Update the appearance stream for this field. Note that qpdf's + // abilitiy to generate appearance streams is limited. We only + // generate appearance streams for streams of type text or choice. + // The appearance uses the default parameters provided in the + // file, and it only supports ASCII characters. Quadding is + // currently ignored. While this functionality is limited, it + // should do a decent job on properly constructed PDF files when + // field values are restricted to ASCII characters. + QPDF_DLL + void generateAppearance(QPDFAnnotationObjectHelper&); + private: void setRadioButtonValue(QPDFObjectHandle name); void setCheckBoxValue(bool value); + void generateTextAppearance(QPDFAnnotationObjectHelper&); class Members { |