File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 52
52
# Schemas".
53
53
PDFX_NAMESPACE = "http://ns.adobe.com/pdfx/1.3/"
54
54
55
+ # PDF/A
56
+ PDFAID_NAMESPACE = "http://www.aiim.org/pdfa/ns/id/"
57
+
55
58
iso8601 = re .compile (
56
59
"""
57
60
(?P<year>[0-9]{4})
@@ -363,6 +366,12 @@ def _get_text(self, element: XmlElement) -> str:
363
366
"""An identifier for a specific incarnation of a document, updated each
364
367
time a file is saved."""
365
368
369
+ pdfaid_part = property (_getter_single (PDFAID_NAMESPACE , "part" ))
370
+ """The part of the PDF/A standard that the document conforms to (e.g., 1, 2, 3)."""
371
+
372
+ pdfaid_conformance = property (_getter_single (PDFAID_NAMESPACE , "conformance" ))
373
+ """The conformance level within the PDF/A standard (e.g., 'A', 'B', 'U')."""
374
+
366
375
@property
367
376
def custom_properties (self ) -> Dict [Any , Any ]:
368
377
"""
Original file line number Diff line number Diff line change @@ -272,3 +272,25 @@ class Tst: # to replace pdf
272
272
273
273
assert xmp_info is not None
274
274
f (xmp_info )
275
+
276
+
277
+ @pytest .mark .samples
278
+ def test_pdfa_xmp_metadata_with_values ():
279
+ """Test PDF/A XMP metadata extraction from a file with PDF/A metadata."""
280
+ reader = PdfReader (SAMPLE_ROOT / "021-pdfa" / "crazyones-pdfa.pdf" )
281
+ xmp = reader .xmp_metadata
282
+
283
+ assert xmp is not None
284
+ assert xmp .pdfaid_part == "1"
285
+ assert xmp .pdfaid_conformance == "B"
286
+
287
+
288
+ @pytest .mark .samples
289
+ def test_pdfa_xmp_metadata_without_values ():
290
+ """Test PDF/A XMP metadata extraction from a file without PDF/A metadata."""
291
+ reader = PdfReader (SAMPLE_ROOT / "020-xmp" / "output_with_metadata_pymupdf.pdf" )
292
+ xmp = reader .xmp_metadata
293
+
294
+ assert xmp is not None
295
+ assert xmp .pdfaid_part is None
296
+ assert xmp .pdfaid_conformance is None
You can’t perform that action at this time.
0 commit comments