/src/qpdf/include/qpdf/QPDFAnnotationObjectHelper.hh
Line | Count | Source |
1 | | // Copyright (c) 2005-2021 Jay Berkenbilt |
2 | | // Copyright (c) 2022-2026 Jay Berkenbilt and Manfred Holger |
3 | | // |
4 | | // This file is part of qpdf. |
5 | | // |
6 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
7 | | // in compliance with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
12 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
13 | | // or implied. See the License for the specific language governing permissions and limitations under |
14 | | // the License. |
15 | | // |
16 | | // Versions of qpdf prior to version 7 were released under the terms of version 2.0 of the Artistic |
17 | | // License. At your option, you may continue to consider qpdf to be licensed under those terms. |
18 | | // Please see the manual for additional information. |
19 | | |
20 | | #ifndef QPDFANNOTATIONOBJECTHELPER_HH |
21 | | #define QPDFANNOTATIONOBJECTHELPER_HH |
22 | | |
23 | | #include <qpdf/Constants.h> |
24 | | #include <qpdf/QPDFObjectHelper.hh> |
25 | | |
26 | | #include <qpdf/DLL.h> |
27 | | |
28 | | class QPDFAnnotationObjectHelper: public QPDFObjectHelper |
29 | | { |
30 | | public: |
31 | | QPDF_DLL |
32 | | QPDFAnnotationObjectHelper(QPDFObjectHandle); |
33 | | |
34 | 0 | ~QPDFAnnotationObjectHelper() override = default; |
35 | | |
36 | | // This class provides helper methods for annotations. More functionality will likely be added |
37 | | // in the future. |
38 | | |
39 | | // Some functionality for annotations is also implemented in QPDFAcroFormDocumentHelper and |
40 | | // QPDFFormFieldObjectHelper. In some cases, functions defined there work for other annotations |
41 | | // besides widget annotations, but they are implemented with form fields so that they can |
42 | | // properly handle form fields when needed. |
43 | | |
44 | | // Return the subtype of the annotation as a string (e.g. "/Widget"). Returns an empty string |
45 | | // if the subtype (which is required by the spec) is missing. |
46 | | QPDF_DLL |
47 | | std::string getSubtype(); |
48 | | |
49 | | QPDF_DLL |
50 | | QPDFObjectHandle::Rectangle getRect(); |
51 | | |
52 | | QPDF_DLL |
53 | | QPDFObjectHandle getAppearanceDictionary(); |
54 | | |
55 | | // Return the appearance state as given in "/AS", or an empty string if none is given. |
56 | | QPDF_DLL |
57 | | std::string getAppearanceState(); |
58 | | |
59 | | // Return flags from "/F". The value is a logical or of pdf_annotation_flag_e as defined in |
60 | | // qpdf/Constants.h. |
61 | | QPDF_DLL |
62 | | int getFlags(); |
63 | | |
64 | | // Return a specific stream. "which" may be one of "/N", "/R", or "/D" to indicate the normal, |
65 | | // rollover, or down appearance stream. (Any value may be passed to "which"; if an appearance |
66 | | // stream of that name exists, it will be returned.) If the value associated with "which" in the |
67 | | // appearance dictionary is a subdictionary, an appearance state may be specified to select |
68 | | // which appearance stream is desired. If not specified, the appearance state in "/AS" will |
69 | | // used. |
70 | | QPDF_DLL |
71 | | QPDFObjectHandle getAppearanceStream(std::string const& which, std::string const& state = ""); |
72 | | |
73 | | // Generate text suitable for addition to the containing page's content stream that draws this |
74 | | // annotation's appearance stream as a form XObject. The value "name" is the resource name that |
75 | | // will be used to refer to the form xobject. The value "rotate" should be set to the page's |
76 | | // /Rotate value or 0 if none. The values of required_flags and forbidden_flags are constructed |
77 | | // by logically "or"ing annotation flags of type pdf_annotation_flag_e defined in |
78 | | // qpdf/Constants.h. Content will be returned only if all required_flags are set and no |
79 | | // forbidden_flags are set. For example, including an_no_view in forbidden_flags could be useful |
80 | | // for creating an on-screen view, and including an_print to required_flags could be useful if |
81 | | // preparing to print. |
82 | | QPDF_DLL |
83 | | std::string getPageContentForAppearance( |
84 | | std::string const& name, |
85 | | int rotate, |
86 | | int required_flags = 0, |
87 | | int forbidden_flags = an_invisible | an_hidden); |
88 | | |
89 | | private: |
90 | | class Members |
91 | | { |
92 | | friend class QPDFAnnotationObjectHelper; |
93 | | |
94 | | public: |
95 | | ~Members() = default; |
96 | | |
97 | | private: |
98 | | Members() = default; |
99 | | Members(Members const&) = delete; |
100 | | }; |
101 | | |
102 | | std::shared_ptr<Members> m; |
103 | | }; |
104 | | |
105 | | #endif // QPDFANNOTATIONOBJECTHELPER_HH |