All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDFACompliance.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFPDFAPDFACompliance
6 #define PDFTRON_H_CPPPDFPDFAPDFACompliance
7 
8 #include <vector>
9 #include <PDF/PDFDoc.h>
10 #include <C/PDF/PDFA/TRN_PDFACompliance.h>
11 #include <Common/UString.h>
12 
13 
14 namespace pdftron {
15  namespace PDF {
16  namespace PDFA {
17  class PDFAOptions;
18 
53 {
54 public:
55 
69  {
82  };
83 
84  enum ErrorCode
85  {
86  // PDF/A-1 Level B Validation Errors --------------------------------
93  e_PDFA1_2_1 =121,
94  e_PDFA1_2_2 =122,
95  e_PDFA1_3_1 =131,
96  e_PDFA1_3_2 =132,
97  e_PDFA1_3_3 =133,
98  e_PDFA1_3_4 =134,
99  e_PDFA1_4_1 =141,
100  e_PDFA1_4_2 =142,
101  e_PDFA1_6_1 =161,
102  e_PDFA1_7_1 =171,
103  e_PDFA1_7_2 =172,
104  e_PDFA1_7_3 =173,
105  e_PDFA1_7_4 =174,
106  e_PDFA1_8_1 =181,
107  e_PDFA1_8_2 =182,
108  e_PDFA1_8_3 =183,
109  e_PDFA1_8_4 =184,
110  e_PDFA1_8_5 =185,
111  e_PDFA1_8_6 =186,
112  e_PDFA1_8_7 =187,
113  e_PDFA1_10_1 =1101,
114  e_PDFA1_11_1 =1111,
115  e_PDFA1_11_2 =1112,
116  e_PDFA1_12_1 =1121,
117  e_PDFA1_12_2 =1122,
118  e_PDFA1_12_3 =1123,
119  e_PDFA1_12_4 =1124,
120  e_PDFA1_12_5 =1125,
121  e_PDFA1_12_6 =1126,
122  e_PDFA1_12_7 =1127,
123  e_PDFA1_12_11 =11211,
124  e_PDFA1_12_13 =11213,
125  e_PDFA1_12_15 =11215,
126  e_PDFA1_13_1 =1131,
127  e_PDFA2_2_1 =221,
128  e_PDFA2_3_2 =232,
129  e_PDFA2_3_3 =233,
133  e_PDFA2_4_1 =241,
134  e_PDFA2_4_2 =242,
135  e_PDFA2_4_3 =243,
136  e_PDFA2_4_4 =244,
137  e_PDFA2_5_1 =251,
138  e_PDFA2_5_2 =252,
139  e_PDFA2_6_1 =261,
140  e_PDFA2_7_1 =271,
141  e_PDFA2_8_1 =281,
142  e_PDFA2_9_1 =291,
143  e_PDFA2_10_1 =2101,
144  e_PDFA3_2_1 =321,
145  e_PDFA3_2_2 =322,
146  e_PDFA3_2_3 =323,
147  e_PDFA3_2_4 =324,
148  e_PDFA3_2_5 =325,
149  e_PDFA3_2_6 =326,
150  e_PDFA3_2_7 =327,
151  e_PDFA3_3_1 =331,
152  e_PDFA3_3_2 =332,
155  e_PDFA3_4_1 =341,
156  e_PDFA3_5_1 =351,
157  e_PDFA3_5_2 =352,
158  e_PDFA3_5_3 =353,
159  e_PDFA3_5_4 =354,
160  e_PDFA3_5_5 =355,
161  e_PDFA3_5_6 =356,
162  e_PDFA3_5_7 =357,
163  e_PDFA3_6_1 =361,
164  e_PDFA3_7_1 =371,
165  e_PDFA3_7_2 =372,
166  e_PDFA3_7_3 =373,
167  e_PDFA4_1 =41,
168  e_PDFA4_2 =42,
169  e_PDFA4_3 =43,
170  e_PDFA4_4 =44,
171  e_PDFA4_5 =45,
172  e_PDFA4_6 =46,
173  e_PDFA5_2_1 =521,
174  e_PDFA5_2_2 =522,
175  e_PDFA5_2_3 =523,
176  e_PDFA5_2_4 =524,
177  e_PDFA5_2_5 =525,
178  e_PDFA5_2_6 =526,
179  e_PDFA5_2_7 =527,
180  e_PDFA5_2_8 =528,
181  e_PDFA5_2_9 =529,
182  e_PDFA5_2_10 =5210,
183  e_PDFA5_2_11 =5211,
184  e_PDFA5_3_1 =531,
197  e_PDFA6_1_1 =611,
198  e_PDFA6_1_2 =612,
199  e_PDFA6_2_1 =621,
200  e_PDFA6_2_2 =622,
201  e_PDFA6_2_3 =623,
202  e_PDFA7_2_1 =721,
203  e_PDFA7_2_2 =722,
204  e_PDFA7_2_3 =723,
205  e_PDFA7_2_4 =724,
206  e_PDFA7_2_5 =725,
207  e_PDFA7_3_1 =731,
208  e_PDFA7_3_2 =732,
209  e_PDFA7_3_3 =733,
210  e_PDFA7_3_4 =734,
211  e_PDFA7_3_5 =735,
212  e_PDFA7_3_6 =736,
213  e_PDFA7_3_7 =737,
214  e_PDFA7_3_8 =738,
215  e_PDFA7_3_9 =739,
216  e_PDFA7_5_1 =751,
217  e_PDFA7_8_1 =781,
218  e_PDFA7_8_2 =782,
219  e_PDFA7_8_3 =783,
220  e_PDFA7_8_4 =784,
221  e_PDFA7_8_5 =785,
222  e_PDFA7_8_6 =786,
223  e_PDFA7_8_7 =787,
224  e_PDFA7_8_8 =788,
225  e_PDFA7_8_9 =789,
226  e_PDFA7_8_10 =7810,
227  e_PDFA7_8_11 =7811,
228  e_PDFA7_8_12 =7812,
229  e_PDFA7_8_13 =7813,
230  e_PDFA7_8_14 =7814,
231  e_PDFA7_8_15 =7815,
232  e_PDFA7_8_16 =7816,
233  e_PDFA7_8_17 =7817,
234  e_PDFA7_8_18= 7818,
235  e_PDFA7_8_19= 7819,
236  e_PDFA7_8_20 =7820,
237  e_PDFA7_8_21 =7821,
238  e_PDFA7_8_22 =7822,
239  e_PDFA7_8_23 =7823,
240  e_PDFA7_8_24 =7824,
241  e_PDFA7_8_25 =7825,
242  e_PDFA7_8_26 =7826,
243  e_PDFA7_8_27 =7827,
244  e_PDFA7_8_28 =7828,
245  e_PDFA7_8_29 =7829,
246  e_PDFA7_8_30 =7830,
247  e_PDFA7_8_31 =7831,
248  e_PDFA7_11_1 =7111,
249  e_PDFA7_11_2 =7112,
250  e_PDFA7_11_3 =7113,
251  e_PDFA7_11_4 =7114,
252  e_PDFA7_11_5 =7115,
253  e_PDFA9_1 =91,
254  e_PDFA9_2 =92,
255  e_PDFA9_3 =93,
256  e_PDFA9_4 =94,
257  e_PDFA9_5 =95,
258 
259  // PDF/A-1 Level A Validation Errors --------------------------------
260  e_PDFA3_8_1 =381,
261  e_PDFA8_2_2 =822,
265  e_PDFA8_4_1 =841,
266 
267 
268  // PDF/A-2 Level B Validation Errors --------------------------------
269  e_PDFA1_2_3 =123,
270  e_PDFA1_3_5 =135,
271  e_PDFA1_10_2 =1102,
272  e_PDFA1_10_3 =1103,
273  e_PDFA1_12_8 =1128,
274  e_PDFA1_12_9 =1129,
275  e_PDFA1_12_10 =11210,
276  e_PDFA1_12_12 =11212,
277  e_PDFA1_12_14 =11214,
278  e_PDFA1_13_5 =1135,
279  e_PDFA2_3_10 =2310,
280  e_PDFA2_4_2_10 =24210,
281  e_PDFA2_4_2_11 =24211,
282  e_PDFA2_4_2_12 =24212,
283  e_PDFA2_4_2_13 =24213,
284  e_PDFA2_5_10 =2510,
285  e_PDFA2_5_11 =2511,
286  e_PDFA2_5_12 =2512,
292  e_PDFA2_10_20 =21020,
293  e_PDFA2_10_21 =21021,
294  e_PDFA3_3_4 =334,
295  e_PDFA5_2_12 =5212,
296  e_PDFA8_1 =81,
297  e_PDFA11_0_0 =11000,
298  e_PDFA6_10_0 =6100,
299  e_PDFA6_10_1 =6101,
300  e_PDFA6_2_11_5 =62115,
301  e_PDFA6_2_11_6 =62116,
302  e_PDFA6_2_11_7 =62117,
303  e_PDFA6_2_11_8 =62118,
305  e_PDFA6_9_1 =69001,
306  e_PDFA6_9_3 =69003,
307 
308  // PDF/A-3 Validation Errors --------------------------------------
313 
314  // PDF/A-4 Validation Errors --------------------------------------
323  e_PDFA_4_6_1_12_1 = 461121,
327  e_PDFA_4_6_9_5 = 4695,
331 
333  };
334 
335 
350  PDFACompliance(bool convert, const UString& file_path, const char* password = 0, Conformance conf = e_Level1B, ErrorCode* exceptions = 0, int num_exceptions = 0, int max_ref_objs = 10, bool first_stop = false);
351 
368  PDFACompliance(bool convert, const char* buf, size_t buf_size, const char* password = 0, Conformance conf = e_Level1B, ErrorCode* exceptions = 0, int num_exceptions = 0, int max_ref_objs = 10, bool first_stop = false);
369  PDFACompliance(bool convert, const unsigned char* buf, size_t buf_size, const char* password = 0, Conformance conf = e_Level1B, ErrorCode* exceptions = 0, int num_exceptions = 0, int max_ref_objs = 10, bool first_stop = false);
370 
382  PDFACompliance(bool convert, const UString& file_path, const PDFA::PDFAOptions& in_options);
383 
397  PDFACompliance(bool convert, const char* buf, size_t buf_size, const PDFA::PDFAOptions& in_options);
398  PDFACompliance(bool convert, const unsigned char* buf, size_t buf_size, const PDFA::PDFAOptions& in_options);
399 
408  void SaveAs(const UString& file_path, bool linearized = false);
409 
418  std::vector<unsigned char> SaveAs(bool linearized = false);
419 
420 #ifndef SWIG
421 
432  void SaveAs(const char* &out_buf, size_t& out_buf_size, bool linearized = false);
433 #endif
434 
438  size_t GetErrorCount();
439 
448 
453  size_t GetRefObjCount(ErrorCode id);
454 
466  size_t GetRefObj(ErrorCode id, size_t err_idx);
467 
472  static const char* GetPDFAErrorMessage(ErrorCode id);
473 
480 
484  ~PDFACompliance();
485 
489  void Destroy();
490 
491 #ifndef SWIGHIDDEN
492  PDFACompliance(TRN_PDFACompliance impl) : mp_pdfac(impl) {}
493  TRN_PDFACompliance mp_pdfac;
494 #endif
495 private:
497  PDFACompliance& operator= (const PDFACompliance&);
498 };
499 
500 
501  }; // namespace PDFA
502  }; // namespace PDF
503 }; // namespace pdftron
504 
505 #include <Impl/PDFACompliance.inl>
506 
507 #endif // PDFTRON_H_CPPPDFPDFAPDFACompliance
&#39;pdfaField:valueType&#39; not found.
The Metadata object stream contains Filter key.
A BaseFont entry is missing or has invalid type.
An ICCBased CMYK color space is identical to the current PDF/A OutputIntent color profile or the curr...
A conforming file shall not contain any real number closer to zero than +/- 1.175 x 10^-38...
&#39;pdfaProperty:valueType&#39; not found.
Some text can&#39;t be mapped to Unicode.
Transparency used (Page or Form XObject with transparency group).
PDFACompliance::ErrorCode GetError(size_t idx)
&#39;pdfaExtension:schemas&#39; is using a wrong value type.
Symbolic TrueType fonts shall not contain an Encoding entry in the font dictionary, and the &#39;cmap&#39; subtable in the embedded font program shall either contain the Microsoft Symbol (3,0 - Platform ID=3, Encoding ID=0) or the Mac Roman (1,0 - Platform ID=1, Encoding ID=0) encoding.
XMP property not predefined and no extension schema present.
A Widget annotation does not have an appearance dictionary.
Widths in embedded font are inconsistent with /Widths entry in the font dictionary.
JPEG2000: The bit-depth JPEG2000 data must be in range 1-38.
The file trailer dictionary&#39;s ID values are empty.
AP has an N entry whose value is invalid.
Maximum number of DeviceN components (8) exceeded.
A conforming file shall not contain any real number outside the range of +/- 3.403 x 10^38...
&#39;pdfaType:field&#39; is using a wrong value type.
Page Group entry is missing in a document without OutputIntent.
Using JPEG2000 compression (PDF 1.4 compatibility).
The NeedAppearances flag in the interactive form dictionary is set to true.
Invalid format for Lang entry in document catalog or in a structure element dictionary.
Transparency used (Blend mode is not &#39;Normal&#39; or &#39;Compatible&#39;).
The required field namespace prefix is &#39;pdfaProperty&#39;.
A non-standard structure type does not map to a standard type.
Subsection header: starting object number and range not separated by a single space.
The number of nested q/Q operators is greater than 28.
Annotation which has non-zero width and height and is not a popup or link does not have an appearance...
If a document information dictionary is present, it shall only contain a ModDate entry.
3D stream shall have a Subtype entry with a value which is either U3D or PRC.
An annotation dictionary contains the CA key with a value other than 1.0.
For all non-symbolic TrueType fonts used for rendering, the embedded TrueType font program shall cont...
&#39;pdfaType:type&#39; is using a wrong value type.
&#39;endobj&#39; not preceded by EOL marker
Maximum value (65535) of a CID (character identifier) exceeded.
Required property &#39;valueType&#39; missing in PDF/A Schema Value Type.
Real number&#39;s integer part has excessive absolute magnitude; it must be 32767.0 or less...
Catalog contains NeedsRendering.
An annotation&#39;s IC entry present but no OutputIntent present.
DestOutputProfile-s in OutputIntents array do not match.
Document information entry &#39;CreationDate&#39; not synchronized with XMP.
Optional content Contains AS entry.
The ActualText entry shall not contain any PUA values.
&#39;xref&#39; and cross reference subsection header not separated by a single EOL marker.
&#39;pdfaField:description&#39; not found.
&#39;bytes&#39; and &#39;encoding&#39; attributes are not allowed in the header of an XMP packet. ...
&#39;pdfaField:valueType&#39; is using a wrong type.
Device-specific color space used in an alternate color space.
Document does not start with % character.
An annotation dictionary is missing F key.
An annotation&#39;s C entry present but OutputIntent has non-RGB destination profile. ...
The trailer dictionary does not contain ID.
Transparency used (XObject with soft mask).
Wrong value type for predefined XMP property.
Trailer dictionary contains Encrypt.
An interactive form field contains an action.
Linearized file: ID in 1st page and last trailer are different.
The &#39;endstream&#39; token is not preceded by EOL.
The Info key shall not be present in the trailer dictionary unless there exists a PieceInfo entry in ...
A non-standard simple font dictionary has missing or invalid FirstChar entry.
An annotation&#39;s &#39;Print&#39; flag is not set.
Embedded Type1 font descriptor&#39;s CharSet string does not list all glyphs.
Transparency used (&#39;CA&#39; value is not 1.0).
Embedded file has no MIME type entry.
Caret annotation is not permitted.
The required namespace prefix for extension schema is &#39;pdfaExtension&#39;.
A conforming file shall not contain any string longer than 32767 bytes.
An annotation&#39;s C entry present but no OutputIntent present.
The font program is not embedded.
alternateSpace is different in Separations with the same colorant name.
Array contains more than 8191 elements.
Required description for &#39;pdfaField::valueType&#39; is missing.
Polygon annotation is not permitted.
&#39;pdfaType:description&#39; not found.
Contains a non-predefined Named action.
&#39;pdfaField:name&#39; is using a wrong value type.
FileSpec is missing F or UF key.
If the Version key is present in the document catalog dictionary, the first character in its value sh...
Contains compressed object streams (PDF 1.4 compatibility).
The document catalog does not contain Metadata stream.
The required field namespace prefix is &#39;pdfaSchema&#39;.
&#39;pdfaType:namespaceURI&#39; not found.
Widths array is missing or has invalid size.
An annotation&#39;s &#39;Hidden&#39; flag is set.
&#39;pdfaField:description&#39; is using a wrong type.
JPEG2000: Only the JPX baseline is supported.
size_t GetRefObjCount(ErrorCode id)
A content stream&#39;s named resource not defined by a resource dictionary.
A property doesn&#39;t match its custom schema type.
tintTransform is different in Separations with the same colorant name.
Document information entry &#39;Keywords&#39; not synchronized with XMP.
Object number not preceded by EOL marker.
Image with Interpolate key set to true.
XMP Extension schema doesn&#39;t have a description.
An annotation&#39;s &#39;NoView&#39; flag is set.
A Font dictionary has missing or invalid Subtype entry.
An annotation AP dictionary has entries other than the N entry.
A Font dictionary has missing or invalid Type entry.
AlternatePresentations not allowed.
FileAttachment annotation is not permitted.
&#39;pdfaProperty:name&#39; not found.
PUA characters are missing ActualText.
CIDSet in subset font is incomplete.
Doc catalog is missing EmbeddedFiles key.
&#39;pdfaField:name&#39; not found.
&#39;pdfaType:type&#39; not found.
void SaveAs(const UString &file_path, bool linearized=false)
The font dictionary is missing &#39;ToUnicode&#39; entry.
Catalog contains Requirements key.
Incompatible CIDSystemInfo entries.
The value of Length does not match the number of bytes.
Use of an invalid rendering intent.
The XMP Metadata stream is not valid.
Contains cross-reference streams (PDF 1.4 compatibility).
Each structure element dictionary in the structure hierarchy must have a Type entry with the name val...
Contains an integer value outside of the allowed range [-2^31, 2^31-1],.
A description for a property is missing in &#39;pdfaSchema:property&#39; sequence.
Optional content (layers) not allowed.
Embedded file Params has no ModDate entry.
&#39;pdfaExtension:property&#39; not found.
Exceeds the maximum number (8,388,607) of indirect objects in a PDF file.
Device-specific color space used, but no GTS_PDFA1 OutputIntent.
Contains an XObject that is not supported (e.g. PostScript XObject).
A document catalog or a page dictionary contains an AA entry and its value contains key(s) not from t...
Document information entry &#39;Creator&#39; not synchronized with XMP.
Document information entry &#39;Title&#39; not synchronized with XMP.
Movie annotation is not permitted.
Doc catalog is missing AF entry.
Image with invalid rendering intent.
&#39;pdfaSchema:valueType&#39; is using a wrong value type.
An annotation AP dictionary does not contain N entry.
Transparency used (&#39;ca&#39; value is not 1.0).
PDFACompliance(TRN_PDFACompliance impl)
&#39;pdfaExtension:schemas&#39; not found.
The PDF is not marked as Tagged PDF.
File header line not followed by % and 4 characters &gt; 127.
Invalid hexadecimal strings used.
Generation number and &#39;obj&#39; are not separated by a single white-space.
Document information entry &#39;ModDate&#39; not synchronized with XMP.
static PDFACompliance::Conformance GetDeclaredConformance(const PDF::PDFDoc &in_doc)
Maximum number of DeviceN colorants (32) exceeded.
&#39;pdfaProperty:name&#39; is using a wrong value type.
Embedded TrueType font program does not define all font glyphs.
A symbolic TrueType font must not specify encoding.
The required field namespace prefix is &#39;pdfaField&#39;.
Document information entry &#39;Subject&#39; not synchronized with XMP.
Maximum length of a string in bytes (65535) exceeded.
Redact annotation is not permitted.
Device-specific color space, does not match OutputIntent.
PDFACompliance(bool convert, const UString &file_path, const char *password=0, Conformance conf=e_Level1B, ErrorCode *exceptions=0, int num_exceptions=0, int max_ref_objs=10, bool first_stop=false)
Embedded file has no AFRelationship.
JPEG2000: All colour channels in the JPEG2000 data must have the same bit-depth.
Page dimensions are outside of the allowed range (3-14400).
The font descriptor dictionary does not include a CharSet string for Type1 font subset.
The document catalog dictionary contains AA entry.
&#39;pdfaSchema:valueType&#39; not found.
Screen annotation is not permitted.
XMP Extension schema is not valid. Required property &#39;namespaceURI&#39; might be missing in PDF/A Schema ...
Invalid PDF/A identifier namespace.
JPEG2000: Invalid number of colour channels.
Object number and generation number are not separated by a single white-space.
size_t GetRefObj(ErrorCode id, size_t err_idx)
Embedded composite (Type0) font program does not define all font glyphs.
Contains an action type that is not permitted.
Document information entry &#39;Producer&#39; not synchronized with XMP.
A non-symbolic TrueType font must use WinAnsiEncoding or MacRomanEncoding.
Sound annotation is not permitted.
An annotation&#39;s &#39;Invisible&#39; flag is set.
Inconsistent WMode in embedded CMap dictionary and stream.
Type 2 CIDFont without CIDToGIDMap.
&#39;pdfaExtension:property&#39; is using a wrong value type.
A CMap references another non-standard CMap.
XMP not included in &#39;xpacket&#39;.
Contains an invalid Transfer Curve in the extended graphics state.
Embedded Type1 font program does not define all font glyphs.
Dictionary contains more than 4095 elements.
A file specification dictionary contains a non-compliant embedded file (EF key).
RichMedia annotation type is not permitted.
Transparency used (ExtGState with soft mask).
The N entry does not match the number of color components in the embedded ICC profile.
The required field namespace prefix is &#39;pdfaType&#39;.
Watermark annotation is not permitted.
A stream object dictionary contains the F, FFilter, or FDecodeParms keys.
&#39;obj&#39; not followed by EOL marker
Some characters map to 0, FEFF or FFFE.
The font descriptor dictionary does not include a CIDSet stream for CIDFont subset.
The &#39;stream&#39; token is not followed by CR and LF or a single LF.
Document information entry &#39;Author&#39; not synchronized with XMP.
A symbolic TrueType font does not have exactly one entry in cmap table.
Optional content Missing Name entry.
&#39;endobj&#39; not followed by EOL marker
static const char * GetPDFAErrorMessage(ErrorCode id)
Incorrect colorant specification in DeviceN.
An annotation&#39;s IC entry present and OutputIntent has non-RGB destination profile.
Invalid PDF/A amendment identifier.
A non-standard simple font dictionary has missing or invalid LastChar entry.
PolyLine annotation is not permitted.