aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-06-21 21:00:00 +0200
committerJay Berkenbilt <ejb@ql.org>2018-06-21 21:57:13 +0200
commit397b097c469db89a49e5a6c2035a0beee2e4d117 (patch)
tree5f2b5e33be51922d210146dd78a1e4a66749691d /include
parent952a665a4ed51400b5925e7cd69f08f0aeb374fe (diff)
downloadqpdf-397b097c469db89a49e5a6c2035a0beee2e4d117.tar.zst
Allow setting a form field's value
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFAcroFormDocumentHelper.hh17
-rw-r--r--include/qpdf/QPDFFormFieldObjectHelper.hh23
2 files changed, 40 insertions, 0 deletions
diff --git a/include/qpdf/QPDFAcroFormDocumentHelper.hh b/include/qpdf/QPDFAcroFormDocumentHelper.hh
index d786fff4..2aa0d377 100644
--- a/include/qpdf/QPDFAcroFormDocumentHelper.hh
+++ b/include/qpdf/QPDFAcroFormDocumentHelper.hh
@@ -135,6 +135,23 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
QPDFFormFieldObjectHelper
getFieldForAnnotation(QPDFAnnotationObjectHelper);
+ // Return the current value of /NeedAppearances. If
+ // /NeedAppearances is missing, return false as that is how PDF
+ // viewers are supposed to interpret it.
+ QPDF_DLL
+ bool getNeedAppearances();
+
+ // Indicate whether appearance streams must be regenerated. If you
+ // modify a field value, you should call setNeedAppearances(true)
+ // unless you also generate an appearance stream for the
+ // corresponding annotation at the same time. If you generate
+ // appearance streams for all fields, you can call
+ // setNeedAppearances(false). If you use
+ // QPDFFormFieldObjectHelper::setV, it will automatically call
+ // this method unless you tell it not to.
+ QPDF_DLL
+ void setNeedAppearances(bool);
+
private:
void analyze();
void traverseField(QPDFObjectHandle field,
diff --git a/include/qpdf/QPDFFormFieldObjectHelper.hh b/include/qpdf/QPDFFormFieldObjectHelper.hh
index b45955a3..c22703aa 100644
--- a/include/qpdf/QPDFFormFieldObjectHelper.hh
+++ b/include/qpdf/QPDFFormFieldObjectHelper.hh
@@ -114,6 +114,29 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
QPDF_DLL
int getQuadding();
+ // Set an attribute to the given value
+ QPDF_DLL
+ void setFieldAttribute(std::string const& key, QPDFObjectHandle value);
+
+ // Set an attribute to the given value as a Unicode string (UTF-16
+ // BE encoded). The input string should be UTF-8 encoded.
+ QPDF_DLL
+ void setFieldAttribute(std::string const& key,
+ std::string const& utf8_value);
+
+ // Set /V (field value) to the given value. Optionally set
+ // /NeedAppearances to true. You can explicitly tell this method
+ // not to set /NeedAppearances if you are going to explicitly
+ // generate an appearance stream yourself.
+ QPDF_DLL
+ void setV(QPDFObjectHandle value, bool need_appearances = true);
+
+ // Set /V (field value) to the given string value encoded as a
+ // Unicode string. The input value should be UTF-8 encoded. See
+ // comments above about /NeedAppearances.
+ QPDF_DLL
+ void setV(std::string const& utf8_value, bool need_appearances = true);
+
private:
class Members
{