Skip to content

Commit c73ad26

Browse files
authored
DOC: Add some references to ISO 32000-2:2020 (PDF 2.0) (#2623)
Add some references to ISO 32000-2:2020 (PDF 2.0) Also reorder to match the PDF 2.0 table order. Add fields to PageLayouts and CatalogDictionary.
1 parent bcc8214 commit c73ad26

File tree

1 file changed

+70
-27
lines changed

1 file changed

+70
-27
lines changed

pypdf/constants.py

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
PDF Reference, third edition, Version 1.4, 2001. ISBN 0-201-75839-3.
77
88
PDF Reference, sixth edition, Version 1.7, 2006.
9+
10+
ISO 32000-2:2020 (PDF 2.0).
911
"""
1012

1113
from enum import IntFlag, auto
@@ -41,7 +43,8 @@ class EncryptionDictAttributes:
4143
"""
4244
Additional encryption dictionary entries for the standard security handler.
4345
44-
TABLE 3.19, Page 122
46+
Table 3.19, Page 122.
47+
Table 21 of the 2.0 manual.
4548
"""
4649

4750
R = "/R" # number, required; revision of the standard security handler
@@ -52,7 +55,10 @@ class EncryptionDictAttributes:
5255

5356

5457
class UserAccessPermissions(IntFlag):
55-
"""TABLE 3.20 User access permissions."""
58+
"""
59+
Table 3.20 User access permissions.
60+
Table 22 of the 2.0 manual.
61+
"""
5662

5763
R1 = 1
5864
R2 = 2
@@ -131,8 +137,10 @@ def all(cls) -> "UserAccessPermissions":
131137

132138
class Resources:
133139
"""
134-
TABLE 3.30 Entries in a resource dictionary.
140+
Table 3.30 Entries in a resource dictionary.
135141
used to be Ressources
142+
143+
Table 34 in the 2.0 reference.
136144
"""
137145

138146
EXT_G_STATE = "/ExtGState" # dictionary, optional
@@ -202,16 +210,22 @@ def PROPERTIES(cls) -> str:
202210

203211

204212
class PagesAttributes:
205-
"""Page Attributes, Table 6.2, Page 52."""
213+
"""
214+
Page Attributes, Table 6.2, Page 52.
215+
Page tree node, Table 30 in the 2.0 reference.
216+
"""
206217

207218
TYPE = "/Type" # name, required; must be /Pages
219+
PARENT = "/Parent" # dictionary, required; indirect reference to pages object
208220
KIDS = "/Kids" # array, required; List of indirect references
209221
COUNT = "/Count" # integer, required; the number of all nodes und this node
210-
PARENT = "/Parent" # dictionary, required; indirect reference to pages object
211222

212223

213224
class PageAttributes:
214-
"""TABLE 3.27 Entries in a page object."""
225+
"""
226+
Table 3.27 Entries in a page object.
227+
Table 31 in the 2.0 reference.
228+
"""
215229

216230
TYPE = "/Type" # name, required; must be /Page
217231
PARENT = "/Parent" # dictionary, required; a pages object
@@ -247,7 +261,7 @@ class PageAttributes:
247261

248262

249263
class FileSpecificationDictionaryEntries:
250-
"""TABLE 3.41 Entries in a file specification dictionary."""
264+
"""Table 3.41 Entries in a file specification dictionary."""
251265

252266
Type = "/Type"
253267
FS = "/FS" # The name of the file system to be used to interpret this file specification
@@ -265,7 +279,10 @@ class FileSpecificationDictionaryEntries:
265279

266280

267281
class StreamAttributes:
268-
"""Table 4.2."""
282+
"""
283+
Table 4.2.
284+
Table 5 in the 2.0 reference.
285+
"""
269286

270287
LENGTH = "/Length" # integer, required
271288
FILTER = "/Filter" # name or array of names, optional
@@ -276,7 +293,9 @@ class FilterTypes:
276293
"""
277294
Table 4.3 of the 1.4 Manual.
278295
279-
Page 354 of the 1.7 Manual
296+
Page 354 of the 1.7 Manual.
297+
298+
Table 6 of the 2.0 manual.
280299
"""
281300

282301
ASCII_HEX_DECODE = "/ASCIIHexDecode" # abbreviation: AHx
@@ -290,7 +309,10 @@ class FilterTypes:
290309

291310

292311
class FilterTypeAbbreviations:
293-
"""Table 4.44 of the 1.7 Manual (page 353ff)."""
312+
"""
313+
Table 4.44 of the 1.7 Manual (page 353ff).
314+
Table 92 of the 2.0 manual.
315+
"""
294316

295317
AHx = "/AHx"
296318
A85 = "/A85"
@@ -302,17 +324,23 @@ class FilterTypeAbbreviations:
302324

303325

304326
class LzwFilterParameters:
305-
"""Table 4.4."""
327+
"""
328+
Table 4.4.
329+
Table 8 in the 2.0 reference.
330+
"""
306331

307332
PREDICTOR = "/Predictor" # integer
308-
COLUMNS = "/Columns" # integer
309333
COLORS = "/Colors" # integer
310334
BITS_PER_COMPONENT = "/BitsPerComponent" # integer
335+
COLUMNS = "/Columns" # integer
311336
EARLY_CHANGE = "/EarlyChange" # integer
312337

313338

314339
class CcittFaxDecodeParameters:
315-
"""Table 4.5."""
340+
"""
341+
Table 4.5.
342+
Table 11 in the 2.0 reference.
343+
"""
316344

317345
K = "/K" # integer
318346
END_OF_LINE = "/EndOfLine" # boolean
@@ -325,7 +353,7 @@ class CcittFaxDecodeParameters:
325353

326354

327355
class ImageAttributes:
328-
"""Table 4.39 Pdf Reference 1.7 page 340+"""
356+
"""Table 4.39 PDF Reference 1.7 page 340+"""
329357

330358
TYPE = "/Type" # name, required; must be /XObject
331359
SUBTYPE = "/Subtype" # name, required; must be /Image
@@ -376,7 +404,7 @@ class GoToActionArguments:
376404

377405

378406
class AnnotationDictionaryAttributes:
379-
"""TABLE 8.15 Entries common to all annotation dictionaries."""
407+
"""Table 8.15 Entries common to all annotation dictionaries."""
380408

381409
Type = "/Type"
382410
Subtype = "/Subtype"
@@ -407,7 +435,7 @@ class InteractiveFormDictEntries:
407435

408436

409437
class FieldDictionaryAttributes:
410-
"""TABLE 8.69 Entries common to all field dictionaries (PDF 1.7 reference)."""
438+
"""Table 8.69 Entries common to all field dictionaries (PDF 1.7 reference)."""
411439

412440
FT = "/FT" # name, required for terminal fields
413441
Parent = "/Parent" # dictionary, required for children
@@ -503,7 +531,7 @@ def attributes_dict(cls) -> Dict[str, str]:
503531

504532

505533
class CheckboxRadioButtonAttributes:
506-
"""TABLE 8.76 Field flags common to all field types."""
534+
"""Table 8.76 Field flags common to all field types."""
507535

508536
Opt = "/Opt" # Options, Optional
509537

@@ -542,15 +570,15 @@ def attributes_dict(cls) -> Dict[str, str]:
542570

543571

544572
class FieldFlag(IntFlag):
545-
"""TABLE 8.70 Field flags common to all field types."""
573+
"""Table 8.70 Field flags common to all field types."""
546574

547575
READ_ONLY = 1
548576
REQUIRED = 2
549577
NO_EXPORT = 4
550578

551579

552580
class DocumentInformationAttributes:
553-
"""TABLE 10.2 Entries in the document information dictionary."""
581+
"""Table 10.2 Entries in the document information dictionary."""
554582

555583
TITLE = "/Title" # text string, optional
556584
AUTHOR = "/Author" # text string, optional
@@ -564,12 +592,17 @@ class DocumentInformationAttributes:
564592

565593

566594
class PageLayouts:
567-
"""Page 84, PDF 1.4 reference."""
595+
"""
596+
Page 84, PDF 1.4 reference.
597+
Page 115, PDF 2.0 reference.
598+
"""
568599

569600
SINGLE_PAGE = "/SinglePage"
570601
ONE_COLUMN = "/OneColumn"
571602
TWO_COLUMN_LEFT = "/TwoColumnLeft"
572603
TWO_COLUMN_RIGHT = "/TwoColumnRight"
604+
TWO_PAGE_LEFT = "/TwoPageLeft" # (PDF 1.5)
605+
TWO_PAGE_RIGHT = "/TwoPageRight" # (PDF 1.5)
573606

574607

575608
class GraphicsStateParameters:
@@ -605,10 +638,14 @@ class GraphicsStateParameters:
605638

606639

607640
class CatalogDictionary:
608-
"""Table 3.25 in the 1.7 reference."""
641+
"""
642+
Table 3.25 in the 1.7 reference.
643+
Table 29 in the 2.0 reference.
644+
"""
609645

610646
TYPE = "/Type" # name, required; must be /Catalog
611647
VERSION = "/Version" # name
648+
EXTENSIONS = "/Extensions" # dictionary, optional; ISO 32000-1
612649
PAGES = "/Pages" # dictionary, required
613650
PAGE_LABELS = "/PageLabels" # number tree, optional
614651
NAMES = "/Names" # dictionary, optional
@@ -635,6 +672,9 @@ class CatalogDictionary:
635672
REQUIREMENTS = "/Requirements" # array, optional
636673
COLLECTION = "/Collection" # dictionary, optional
637674
NEEDS_RENDERING = "/NeedsRendering" # boolean, optional
675+
DSS = "/DSS" # dictionary, optional
676+
AF = "/AF" # array of dictionaries, optional
677+
D_PART_ROOT = "/DPartRoot" # dictionary, optional
638678

639679

640680
class OutlineFontFlag(IntFlag):
@@ -645,17 +685,20 @@ class OutlineFontFlag(IntFlag):
645685

646686

647687
class PageLabelStyle:
648-
"""Table 8.10 in the 1.7 reference."""
688+
"""
689+
Table 8.10 in the 1.7 reference.
690+
Table 161 in the 2.0 reference.
691+
"""
649692

650-
DECIMAL = "/D" # Decimal arabics
651-
LOWERCASE_ROMAN = "/r" # Lowercase roman numbers
652-
UPPERCASE_ROMAN = "/R" # Uppercase roman numbers
653-
LOWERCASE_LETTER = "/a" # Lowercase letters
693+
DECIMAL = "/D" # Decimal Arabic numerals
694+
UPPERCASE_ROMAN = "/R" # Uppercase Roman numerals
695+
LOWERCASE_ROMAN = "/r" # Lowercase Roman numerals
654696
UPPERCASE_LETTER = "/A" # Uppercase letters
697+
LOWERCASE_LETTER = "/a" # Lowercase letters
655698

656699

657700
class AnnotationFlag(IntFlag):
658-
"""See 12.5.3 "Annotation Flags"."""
701+
"""See §12.5.3 "Annotation Flags"."""
659702

660703
INVISIBLE = 1
661704
HIDDEN = 2

0 commit comments

Comments
 (0)