1 /* Copyright (c) 2005-2021 Jay Berkenbilt 2 * 3 * This file is part of qpdf. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * Versions of qpdf prior to version 7 were released under the terms 18 * of version 2.0 of the Artistic License. At your option, you may 19 * continue to consider qpdf to be licensed under those terms. Please 20 * see the manual for additional information. 21 */ 22 23 #ifndef QPDFCONSTANTS_H 24 #define QPDFCONSTANTS_H 25 26 /* Keep this file 'C' compatible so it can be used from the C and C++ 27 * interfaces. 28 */ 29 30 /* Error Codes */ 31 32 enum qpdf_error_code_e 33 { 34 qpdf_e_success = 0, 35 qpdf_e_internal, /* logic/programming error -- indicates bug */ 36 qpdf_e_system, /* I/O error, memory error, etc. */ 37 qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */ 38 qpdf_e_password, /* incorrect password for encrypted file */ 39 qpdf_e_damaged_pdf, /* syntax errors or other damage in PDF */ 40 qpdf_e_pages, /* erroneous or unsupported pages structure */ 41 qpdf_e_object, /* type/bounds errors accessing objects */ 42 }; 43 44 /* Object Types */ 45 46 /* PDF objects represented by QPDFObjectHandle or, in the C API, by 47 * qpdf_oh, have a unique type code that has one of the values in the 48 * list below. As new object types are added to qpdf, additional items 49 * may be added to the list, so code that switches on these values 50 * should take that into consideration. (Maintainer note: it would be 51 * better to call this qpdf_ot_* rather than ot_* to reduce likelihood 52 * of name collision, but since QPDFObject::object_type_e is an alias 53 * to this type, changing the names of the values breaks backward 54 * compatibility.) 55 */ 56 enum qpdf_object_type_e { 57 /* Object types internal to qpdf */ 58 ot_uninitialized, 59 ot_reserved, 60 /* Object types that can occur in the main document */ 61 ot_null, 62 ot_boolean, 63 ot_integer, 64 ot_real, 65 ot_string, 66 ot_name, 67 ot_array, 68 ot_dictionary, 69 ot_stream, 70 /* Additional object types that can occur in content streams */ 71 ot_operator, 72 ot_inlineimage, 73 /* NOTE: if adding to this list, update QPDFObject.hh */ 74 }; 75 76 /* Write Parameters. See QPDFWriter.hh for details. */ 77 78 enum qpdf_object_stream_e 79 { 80 qpdf_o_disable = 0, /* disable object streams */ 81 qpdf_o_preserve, /* preserve object streams */ 82 qpdf_o_generate /* generate object streams */ 83 }; 84 enum qpdf_stream_data_e 85 { 86 qpdf_s_uncompress = 0, /* uncompress stream data */ 87 qpdf_s_preserve, /* preserve stream data compression */ 88 qpdf_s_compress /* compress stream data */ 89 }; 90 91 /* Stream data flags */ 92 93 /* See pipeStreamData in QPDFObjectHandle.hh for details on these flags. */ 94 enum qpdf_stream_encode_flags_e 95 { 96 qpdf_ef_compress = 1 << 0, /* compress uncompressed streams */ 97 qpdf_ef_normalize = 1 << 1, /* normalize content stream */ 98 }; 99 enum qpdf_stream_decode_level_e 100 { 101 /* These must be in order from less to more decoding. */ 102 qpdf_dl_none = 0, /* preserve all stream filters */ 103 qpdf_dl_generalized, /* decode general-purpose filters */ 104 qpdf_dl_specialized, /* also decode other non-lossy filters */ 105 qpdf_dl_all /* also decode lossy filters */ 106 }; 107 108 /* R3 Encryption Parameters */ 109 110 enum qpdf_r3_print_e 111 { 112 qpdf_r3p_full = 0, /* allow all printing */ 113 qpdf_r3p_low, /* allow only low-resolution printing */ 114 qpdf_r3p_none /* allow no printing */ 115 }; 116 117 /* qpdf_r3_modify_e doesn't allow the full flexibility of the spec. It 118 * corresponds to options in Acrobat 5's menus. The new interface in 119 * QPDFWriter offers more granularity and no longer uses this type. 120 */ 121 enum qpdf_r3_modify_e /* Allowed changes: */ 122 { 123 qpdf_r3m_all = 0, /* All editing */ 124 qpdf_r3m_annotate, /* Comments, fill forms, signing, assembly */ 125 qpdf_r3m_form, /* Fill forms, signing, assembly */ 126 qpdf_r3m_assembly, /* Only document assembly */ 127 qpdf_r3m_none /* No modifications */ 128 }; 129 130 /* Form field flags from the PDF spec */ 131 132 enum pdf_form_field_flag_e 133 { 134 /* flags that apply to all form fields */ 135 ff_all_read_only = 1 << 0, 136 ff_all_required = 1 << 1, 137 ff_all_no_export = 1 << 2, 138 139 /* flags that apply to fields of type /Btn (button) */ 140 ff_btn_no_toggle_off = 1 << 14, 141 ff_btn_radio = 1 << 15, 142 ff_btn_pushbutton = 1 << 16, 143 ff_btn_radios_in_unison = 1 << 17, 144 145 /* flags that apply to fields of type /Tx (text) */ 146 ff_tx_multiline = 1 << 12, 147 ff_tx_password = 1 << 13, 148 ff_tx_file_select = 1 << 20, 149 ff_tx_do_not_spell_check = 1 << 22, 150 ff_tx_do_not_scroll = 1 << 23, 151 ff_tx_comb = 1 << 24, 152 ff_tx_rich_text = 1 << 25, 153 154 /* flags that apply to fields of type /Ch (choice) */ 155 ff_ch_combo = 1 << 17, 156 ff_ch_edit = 1 << 18, 157 ff_ch_sort = 1 << 19, 158 ff_ch_multi_select = 1 << 21, 159 ff_ch_do_not_spell_check = 1 << 22, 160 ff_ch_commit_on_sel_change = 1 << 26 161 }; 162 163 /* Annotation flags from the PDF spec */ 164 165 enum pdf_annotation_flag_e 166 { 167 an_invisible = 1 << 0, 168 an_hidden = 1 << 1, 169 an_print = 1 << 2, 170 an_no_zoom = 1 << 3, 171 an_no_rotate = 1 << 4, 172 an_no_view = 1 << 5, 173 an_read_only = 1 << 6, 174 an_locked = 1 << 7, 175 an_toggle_no_view = 1 << 8, 176 an_locked_contents = 1 << 9 177 }; 178 179 #endif /* QPDFCONSTANTS_H */ 180