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-2024 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_13_1 =1131,
123  e_PDFA2_2_1 =221,
124  e_PDFA2_3_2 =232,
125  e_PDFA2_3_3 =233,
129  e_PDFA2_4_1 =241,
130  e_PDFA2_4_2 =242,
131  e_PDFA2_4_3 =243,
132  e_PDFA2_4_4 =244,
133  e_PDFA2_5_1 =251,
134  e_PDFA2_5_2 =252,
135  e_PDFA2_6_1 =261,
136  e_PDFA2_7_1 =271,
137  e_PDFA2_8_1 =281,
138  e_PDFA2_9_1 =291,
139  e_PDFA2_10_1 =2101,
140  e_PDFA3_2_1 =321,
141  e_PDFA3_3_1 =331,
142  e_PDFA3_3_2 =332,
145  e_PDFA3_4_1 =341,
146  e_PDFA3_5_1 =351,
147  e_PDFA3_5_2 =352,
148  e_PDFA3_5_3 =353,
149  e_PDFA3_5_4 =354,
150  e_PDFA3_5_5 =355,
151  e_PDFA3_5_6 =356,
152  e_PDFA3_6_1 =361,
153  e_PDFA3_7_1 =371,
154  e_PDFA3_7_2 =372,
155  e_PDFA3_7_3 =373,
156  e_PDFA4_1 =41,
157  e_PDFA4_2 =42,
158  e_PDFA4_3 =43,
159  e_PDFA4_4 =44,
160  e_PDFA4_5 =45,
161  e_PDFA4_6 =46,
162  e_PDFA5_2_1 =521,
163  e_PDFA5_2_2 =522,
164  e_PDFA5_2_3 =523,
165  e_PDFA5_2_4 =524,
166  e_PDFA5_2_5 =525,
167  e_PDFA5_2_6 =526,
168  e_PDFA5_2_7 =527,
169  e_PDFA5_2_8 =528,
170  e_PDFA5_2_9 =529,
171  e_PDFA5_2_10 =5210,
172  e_PDFA5_2_11 =5211,
173  e_PDFA5_3_1 =531,
187  e_PDFA6_1_1 =611,
188  e_PDFA6_1_2 =612,
189  e_PDFA6_2_1 =621,
190  e_PDFA6_2_2 = 622,
191  e_PDFA6_2_3 = 623,
192  e_PDFA7_2_1 =721,
193  e_PDFA7_2_2 =722,
194  e_PDFA7_2_3 =723,
195  e_PDFA7_2_4 =724,
196  e_PDFA7_2_5 =725,
197  e_PDFA7_3_1 =731,
198  e_PDFA7_3_2 =732,
199  e_PDFA7_3_3 =733,
200  e_PDFA7_3_4 =734,
201  e_PDFA7_3_5 =735,
202  e_PDFA7_3_6 =736,
203  e_PDFA7_3_7 =737,
204  e_PDFA7_3_8 =738,
205  e_PDFA7_3_9 =739,
206  e_PDFA7_5_1 =751,
207  e_PDFA7_8_1 =781,
208  e_PDFA7_8_2 =782,
209  e_PDFA7_8_3 =783,
210  e_PDFA7_8_4 =784,
211  e_PDFA7_8_5 =785,
212  e_PDFA7_8_6 =786,
213  e_PDFA7_8_7 =787,
214  e_PDFA7_8_8 =788,
215  e_PDFA7_8_9 =789,
216  e_PDFA7_8_10 =7810,
217  e_PDFA7_8_11 =7811,
218  e_PDFA7_8_12 =7812,
219  e_PDFA7_8_13 =7813,
220  e_PDFA7_8_14 =7814,
221  e_PDFA7_8_15 =7815,
222  e_PDFA7_8_16 =7816,
223  e_PDFA7_8_17 =7817,
224  e_PDFA7_8_18= 7818,
225  e_PDFA7_8_19= 7819,
226  e_PDFA7_8_20 =7820,
227  e_PDFA7_8_21 =7821,
228  e_PDFA7_8_22 =7822,
229  e_PDFA7_8_23 =7823,
230  e_PDFA7_8_24 =7824,
231  e_PDFA7_8_25 =7825,
232  e_PDFA7_8_26 =7826,
233  e_PDFA7_8_27 =7827,
234  e_PDFA7_8_28 =7828,
235  e_PDFA7_8_29 =7829,
236  e_PDFA7_8_30 =7830,
237  e_PDFA7_8_31 =7831,
238  e_PDFA7_11_1 =7111,
239  e_PDFA7_11_2 =7112,
240  e_PDFA7_11_3 =7113,
241  e_PDFA7_11_4 =7114,
242  e_PDFA7_11_5 =7115,
243  e_PDFA9_1 =91,
244  e_PDFA9_2 =92,
245  e_PDFA9_3 =93,
246  e_PDFA9_4 =94,
247 
248  // PDF/A-1 Level A Validation Errors --------------------------------
249  e_PDFA3_8_1 =381,
250  e_PDFA8_2_2 =822,
254 
255 
256  // PDF/A-2 Level B Validation Errors --------------------------------
257  e_PDFA1_2_3 =123,
258  e_PDFA1_10_2 =1102,
259  e_PDFA1_10_3 =1103,
260  e_PDFA1_12_10 =11210,
261  e_PDFA1_13_5 =1135,
262  e_PDFA2_3_10 =2310,
263  e_PDFA2_4_2_10 =24220,
264  e_PDFA2_4_2_11 =24221,
265  e_PDFA2_4_2_12 =24222,
266  e_PDFA2_4_2_13 =24223,
267  e_PDFA2_5_10 =2510,
268  e_PDFA2_5_11 =2511,
269  e_PDFA2_5_12 =2512,
275  e_PDFA2_10_20 =21020,
276  e_PDFA2_10_21 =21021,
277  e_PDFA11_0_0 =11000,
278  e_PDFA6_10_0 =6100,
279  e_PDFA6_10_1 =6101,
280  e_PDFA6_2_11_5 =62115,
281  e_PDFA6_2_11_6 =62116,
282  e_PDFA6_2_11_7 =62117,
283  e_PDFA6_2_11_8 =62118,
284  e_PDFA6_9_1 =69001,
285  e_PDFA6_9_3 =69003,
286  e_PDFA8_1 =81,
287 
288  // PDF/A-3 Validation Errors --------------------------------------
293 
294  // PDF/A-4 Validation Errors --------------------------------------
303  e_PDFA_4_6_1_12_1 = 461121,
306  e_PDFA_4_6_9_5 = 4695,
309 
311  };
312 
313 
328  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);
329 
346  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);
347  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);
348 
360  PDFACompliance(bool convert, const UString& file_path, const PDFA::PDFAOptions& in_options);
361 
375  PDFACompliance(bool convert, const char* buf, size_t buf_size, const PDFA::PDFAOptions& in_options);
376  PDFACompliance(bool convert, const unsigned char* buf, size_t buf_size, const PDFA::PDFAOptions& in_options);
377 
386  void SaveAs(const UString& file_path, bool linearized = false);
387 
396  std::vector<unsigned char> SaveAs(bool linearized = false);
397 
398 #ifndef SWIG
399 
410  void SaveAs(const char* &out_buf, size_t& out_buf_size, bool linearized = false);
411 #endif
412 
416  size_t GetErrorCount();
417 
426 
431  size_t GetRefObjCount(ErrorCode id);
432 
444  size_t GetRefObj(ErrorCode id, size_t err_idx);
445 
450  static const char* GetPDFAErrorMessage(ErrorCode id);
451 
458 
462  ~PDFACompliance();
463 
467  void Destroy();
468 
469 #ifndef SWIGHIDDEN
470  PDFACompliance(TRN_PDFACompliance impl) : mp_pdfac(impl) {}
471  TRN_PDFACompliance mp_pdfac;
472 #endif
473 private:
475  PDFACompliance& operator= (const PDFACompliance&);
476 };
477 
478 
479  }; // namespace PDFA
480  }; // namespace PDF
481 }; // namespace pdftron
482 
483 #include <Impl/PDFACompliance.inl>
484 
485 #endif // PDFTRON_H_CPPPDFPDFAPDFACompliance
&#39;pdfaField:valueType&#39; not found.
The Metadata object stream contains Filter key.
An ICCBased CMYK color space is identical to the current PDF/A OutputIntent color profile or the curr...
&#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.
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.
AP has an N entry whose value is invalid.
&#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.
Transparency used (Blend mode is not &#39;Normal&#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.
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
Required property &#39;valueType&#39; missing in PDF/A Schema Value Type.
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.
&#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 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 ...
An annotation&#39;s &#39;Print&#39; flag is not set.
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;.
An annotation&#39;s C entry present but no OutputIntent present.
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.
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.
An annotation AP dictionary has entries other than the N 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)
&#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.
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.
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).
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
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.
PolyLine annotation is not permitted.