
    j5j]                    `    d Z ddlmZ ddlZddlmZmZmZmZ  ej                  e
      ZddZy)z OCRmyPDF PDF annotation cleanup.    )annotationsN)
DictionaryNameNameTreePdfc           	        d}t         j                  | j                  vr|S t         j                  | j                  t         j                     vr|S | j                  t         j                     t         j                     }t	        |t
              s|S t        |      }t        d |j                         D              }t        | j                        D ]  \  }}t         j                  |vr|t         j                     D ]  }t	        |t
              st         j                  |vs#t         j                  |t         j                     vrJt        |t         j                     t         j                           }||vs|t        j!                  d|dz    d| d       |t         j                     t         j                  = d}  |S )as  Remove broken goto annotations from a PDF.

    If a PDF contains a GoTo Action that points to a named destination that does not
    exist, Ghostscript PDF/A conversion will fail. In any event, a named destination
    that is not defined is not useful.

    Args:
        pdf: Opened PDF file.

    Returns:
        bool: True if the file was modified, False if not.
    Fc              3      K   | ]  }|  y w)N ).0ks     F/var/www/html/qr/venv/lib/python3.12/site-packages/ocrmypdf/_annots.py	<genexpr>z1remove_broken_goto_annotations.<locals>.<genexpr>*   s     +a+s   z)Disabling a hyperlink annotation on page    z% to a non-existent named destination .T)r   NamesRootDests
isinstancer   r   setkeys	enumeratepagesAnnotsADstrlogwarning)	pdfmodifieddestsnametreenamesnpageannotnamed_destinations	            r   remove_broken_goto_annotationsr(      sm    H zz!zz$**--HHTZZ ,EeZ(H +8==?++ESYY'  4;;d"$++& 	 EeZ0vvU"dffE$&&M&A #E$&&M$&&$9 : - ?Aw G6(),
 $&&M$&&)#	  , O    )r   r   returnbool)__doc__
__future__r   loggingpikepdfr   r   r   r   	getLogger__name__r   r(   r
   r)   r   <module>r2      s-    ' "  3 3g!3r)   