
    TAi                        S r SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SSKrSrSSS.         SS	 jjrSS
 jrSSS jjrSS jrg)zBUtilities for PDF/A production and confirmation with Ghostspcript.    )annotationsN)Iterator)files)PathzsRGB.iccstream_namestream_datac             #  b  #    US L US L :X  d   eU(       a  SOSnU(       a7  Uc   e[         R                  " USS9R                  S5      nU S3U-   v   Sv   U S:w  a  S	U  S
U S3v   SU  S3v   UR                  5        H  u  pgSU SU 3v   M     Sv   U(       a  SU  SUSS   S3v   g g 7f)Nz/streamz/dictT)adobeascii def	{Catalog}z
[/_objdef z /type z /OBJ pdfmark[z <<z  z>> /PUT pdfmark   z /PUT pdfmark)base64	a85encodedecodeitems)alias
dictionaryr   r	   objtypea85_datakeyvals           I/var/www/html/land-ocr/venv/lib/python3.13/site-packages/ocrmypdf/pdfa.py_postscript_objdefr      s      4[D%8999&iGG&&&##Kt<CCGLQ(**5'	??eWC.$$&3%q '
%+ab/*-88 s   B-B/c           	   #     #    Sv   [        SS[        U5      0SUS9 S h  vN   Sv   [        SSS	SS
U  S3S.5       S h  vN   Sv   [        SSS05       S h  vN   g  N@ N! N	7f)Nz%!z
{icc_PDFA}z/Nz/ICCProfiler    z{OutputIntent_PDFA}z/OutputIntentz
/GTS_PDFA1())z/Typez/Sz/DestOutputProfilez/OutputConditionIdentifierr   z/OutputIntentsz[ {OutputIntent_PDFA} ])r   str)icc_nameicc_datacolorss      r   _make_postscriptr&   /   s     
J!	s6{!	   H!$".,-hZq/		
   H!&(AB  #s3   A(A" A(A$A(A&A($A(&A(c                    US:w  a  [        S5      e[        S5      [        -  R                  5       nSR	                  [        XS5      5      n[        U 5      R                  USS9  U $ )a  Create a Postscript PDFMARK file for Ghostscript PDF/A conversion.

pdfmark is an extension to the Postscript language that describes some PDF
features like bookmarks and annotations. It was originally specified Adobe
Distiller, for Postscript to PDF conversion.

Ghostscript uses pdfmark for PDF to PDF/A conversion as well. To use Ghostscript
to create a PDF/A, we need to create a pdfmark file with the necessary metadata.

This function takes care of the many version-specific bugs and peculiarities in
Ghostscript's handling of pdfmark.

The only information we put in specifies that we want the file to be a
PDF/A, and we want to Ghostscript to convert objects to the sRGB colorspace
if it runs into any object that it decides must be converted.

Arguments:
    target_filename: filename to save
    icc: ICC identifier such as 'sRGB'
References:
    Adobe PDFMARK Reference:
    https://opensource.adobe.com/dc-acrobat-sdk-docs/library/pdfmark/
sRGBzOnly supporting sRGBzocrmypdf.data
   r   )encoding)NotImplementedErrorpackage_filesSRGB_ICC_PROFILE_NAME
read_bytesjoinr&   r   
write_text)target_filenameiccbytes_icc_profile
postscripts       r   generate_pdfa_psr6   G   sk    0 f}!"899 	o&)>>jl  +CAFGJ 	$$Z'$B    c                8   [         R                  " U 5       nUR                  5       nUR                  (       d  SSSS.sSSS5        $ 1 SknUR                  R	                  5       nSU 3n0 nXC;   a
  SUS	'   S
US'   XVS'   SSS5        U$ ! , (       d  f       W$ = f)zDetermines if the file claims to be PDF/A compliant.

This only checks if the XMP metadata contains a PDF/A marker. It does not
do full PDF/A validation.
FpdfzNo PDF/A metadata in XMP)passoutputconformanceN>   1a1b2a2b2u3a3b3uzPDF/A-Tr:   pdfar;   r<   )pikepdfopenopen_metadatapdfa_statuslower)filenamer9   pdfmetavalid_part_conformspdfa_status_isor<   	pdfa_dicts          r   file_claims_pdfarP   m   s     
h	3##%""9 
 	 O "--335/0+-	1 $If"(Ih#.- # 
 $ % 
 	$ s   'B
8B


B)
r   r"   r   zdict[str, str]r   z
str | Noner	   zbytes | NonereturnIterator[str])r#   r"   r$   bytesr%   intrQ   rR   )r(   )r2   r   r3   r"   )rK   r   )__doc__
__future__r   r   collections.abcr   importlib.resourcesr   r-   pathlibr   rF   r.   r   r&   r6   rP    r7   r   <module>r[      sn    I "  $ 6  "  # $999 	9
 9 9:0#Lr7   