Added option to set the form available to print
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index fa9c331..111d5b0 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -207,6 +207,22 @@
m_formData->fm->getWidgetAnnotation()->setFlags(flags);
}
+bool FormField::isPrintable() const
+{
+ return (m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagPrint);
+}
+
+void FormField::setPrintable(bool value)
+{
+ unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags();
+ if (value) {
+ flags |= Annot::flagPrint;
+ } else {
+ flags &= ~Annot::flagPrint;
+ }
+ m_formData->fm->getWidgetAnnotation()->setFlags(flags);
+}
+
Link* FormField::activationAction() const
{
Link* action = nullptr;
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index f4c6458..ac00da2 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -155,6 +155,18 @@
void setVisible(bool value);
/**
+ Whether this field is printable.
+ \since 0.79
+ */
+ bool isPrintable() const;
+
+ /**
+ Set whether this field is printable.
+ \since 0.79
+ */
+ void setPrintable(bool value);
+
+ /**
The activation action of this form field.
\note It may be null.
diff --git a/qt5/tests/check_forms.cpp b/qt5/tests/check_forms.cpp
index ec48ce9..f139ed1 100644
--- a/qt5/tests/check_forms.cpp
+++ b/qt5/tests/check_forms.cpp
@@ -14,6 +14,7 @@
void testCheckbox();// Test for issue #655
void testCheckboxIssue159();// Test for issue #159
void testSetIcon();// Test that setIcon will always be valid.
+ void testSetPrintable();
};
void TestForms::testCheckbox()
@@ -148,5 +149,24 @@
QVERIFY( Poppler::FormFieldIconData::getData( anmIcon )->icon );
}
+void TestForms::testSetPrintable()
+{
+ QScopedPointer< Poppler::Document > document(Poppler::Document::load(TESTDATADIR "/unittestcases/form_set_icon.pdf"));
+ QVERIFY( document );
+
+ QScopedPointer< Poppler::Page > page(document->page(0));
+ QVERIFY( page );
+
+ QList<Poppler::FormField*> forms = page->formFields();
+
+ Q_FOREACH (Poppler::FormField *field, forms) {
+ field->setPrintable( true );
+ QCOMPARE( field->isPrintable(), true );
+
+ field->setPrintable( false );
+ QCOMPARE( field->isPrintable(), false );
+ }
+}
+
QTEST_GUILESS_MAIN(TestForms)
#include "check_forms.moc"