aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-03 17:51:58 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-03 17:59:55 +0100
commitca94ac68d9cdb317328398c770c9c755f0004535 (patch)
tree1654a22747dcf94151efa61ce62eda7ff7e967d0 /include
parent06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151 (diff)
downloadqpdf-ca94ac68d9cdb317328398c770c9c755f0004535.tar.zst
Honor flags when flattening annotations
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/Constants.h49
-rw-r--r--include/qpdf/QPDFAnnotationObjectHelper.hh15
-rw-r--r--include/qpdf/QPDFPageDocumentHelper.hh14
3 files changed, 74 insertions, 4 deletions
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index cfd95bef..6daf2614 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -89,4 +89,53 @@ enum qpdf_r3_modify_e /* Allowed changes: */
qpdf_r3m_none /* no modifications */
};
+/* Form field flags from the PDF spec */
+
+enum pdf_form_field_flag_e
+{
+ /* flags that apply to all form fields */
+ ff_all_read_only = 1 << 0,
+ ff_all_required = 1 << 1,
+ ff_all_no_export = 1 << 2,
+
+ /* flags that apply to fields of type /Btn (button) */
+ ff_btn_no_toggle_off = 1 << 14,
+ ff_btn_radio = 1 << 15,
+ ff_btn_pushbutton = 1 << 16,
+ ff_btn_radios_in_unison = 1 << 17,
+
+ /* flags that apply to fields of type /Tx (text) */
+ ff_tx_multiline = 1 << 12,
+ ff_tx_password = 1 << 13,
+ ff_tx_file_select = 1 << 20,
+ ff_tx_do_not_spell_check = 1 << 22,
+ ff_tx_do_not_scroll = 1 << 23,
+ ff_tx_comb = 1 << 24,
+ ff_tx_rich_text = 1 << 25,
+
+ /* flags that apply to fields of type /Ch (choice) */
+ ff_ch_combo = 1 << 17,
+ ff_ch_edit = 1 << 18,
+ ff_ch_sort = 1 << 19,
+ ff_ch_multi_select = 1 << 21,
+ ff_ch_do_not_spell_check = 1 << 22,
+ ff_ch_commit_on_sel_change = 1 << 26
+};
+
+/* Annotation flags from the PDF spec */
+
+enum pdf_annotation_flag_e
+{
+ an_invisible = 1 << 0,
+ an_hidden = 1 << 1,
+ an_print = 1 << 2,
+ an_no_zoom = 1 << 3,
+ an_no_rotate = 1 << 4,
+ an_no_view = 1 << 5,
+ an_read_only = 1 << 6,
+ an_locked = 1 << 7,
+ an_toggle_no_view = 1 << 8,
+ an_locked_contents = 1 << 9
+};
+
#endif /* QPDFCONSTANTS_H */
diff --git a/include/qpdf/QPDFAnnotationObjectHelper.hh b/include/qpdf/QPDFAnnotationObjectHelper.hh
index 47242499..c5d24334 100644
--- a/include/qpdf/QPDFAnnotationObjectHelper.hh
+++ b/include/qpdf/QPDFAnnotationObjectHelper.hh
@@ -23,6 +23,7 @@
#define QPDFANNOTATIONOBJECTHELPER_HH
#include <qpdf/QPDFObjectHelper.hh>
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
@@ -76,10 +77,20 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
// content stream that draws this annotation's appearance stream
// as a form XObject. The value "name" is the resource name that
// will be used to refer to the form xobject. The value "rotate"
- // should be set to the page's /Rotate value or 0 if none.
+ // should be set to the page's /Rotate value or 0 if none. The
+ // values of required_flags and forbidden_flags are constructed by
+ // logically "or"ing annotation flags of type
+ // pdf_annotation_flag_e defined in qpdf/Constants.h. Content will
+ // be returned only if all required_flags are set and no
+ // forbidden_flags are set. For example, including an_no_view in
+ // forbidden_flags could be useful for creating an on-screen view,
+ // and including an_print to required_flags could be useful if
+ // preparing to print.
QPDF_DLL
std::string getPageContentForAppearance(
- std::string const& name, int rotate);
+ std::string const& name, int rotate,
+ int required_flags = 0,
+ int forbidden_flags = an_invisible | an_hidden);
private:
class Members
diff --git a/include/qpdf/QPDFPageDocumentHelper.hh b/include/qpdf/QPDFPageDocumentHelper.hh
index d5446c16..d7876557 100644
--- a/include/qpdf/QPDFPageDocumentHelper.hh
+++ b/include/qpdf/QPDFPageDocumentHelper.hh
@@ -24,6 +24,7 @@
#include <qpdf/QPDFDocumentHelper.hh>
#include <qpdf/QPDFPageObjectHelper.hh>
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
@@ -92,14 +93,23 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
// the annotation from the page. Handles widget annotations
// associated with interactive form fields as a special case,
// including removing the /AcroForm key from the document catalog.
+ // The values passed to required_flags and forbidden_flags are
+ // passed along to
+ // QPDFAnnotationObjectHelper::getPageContentForAppearance. See
+ // comments there in QPDFAnnotationObjectHelper.hh for meanings of
+ // those flags.
QPDF_DLL
- void flattenAnnotations();
+ void flattenAnnotations(
+ int required_flags = 0,
+ int forbidden_flags = an_invisible | an_hidden);
private:
void flattenAnnotationsForPage(
QPDFPageObjectHelper& page,
QPDFObjectHandle& resources,
- QPDFAcroFormDocumentHelper& afdh);
+ QPDFAcroFormDocumentHelper& afdh,
+ int required_flags,
+ int forbidden_flags);
class Members
{