HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/ocrmypdf/__pycache__/cli.cpython-38.pyc
U

��Z^�@�	@s�ddlZddlmZddlmZd�dd�ZGdd�dej�Zeed	ejd
dd�Z	e	j
d
ddd�e	j
dddd�e	j
ddddd�e	j
ddedd�e	j
dddd d!d"gdd#d$�e	j
d%d&d'dd(d)d*�e	j
d+d,ed-d.�e	�d/�Z
e
j
d0d1d2eedd3�d4d�e
j
d5d6d7d8d�e
j
d9d:eedd;�ddd&d<d=�e
j
d>d?d@ejdA�e
j
dBd7ejd�e	�dCdD�Zej
dEedFdG�ej
dHedIdG�ej
dJedKdG�ej
dLedMdG�e	�dNdO�Zej
dPdQd7dRd�ej
dSd7dTd�ej
dUdVd7dWd�ej
dXdYd7dZd�ej
d[d\d7d]d�ej
d^edd_d`�ej
dadeeddb�ddcdd�ej
ded7dfd�ej
dgd7dhd�e	�didj�Zej
dkdld7dmd�ej
dndod7dpd�ej
dqd7drd�ej
dseeddb�dtdudv�e	�dwdx�Zej
dydzeedd{�dd|d}�ej
d~eedd�dd�d�d��ej
d�eedd�dd�d�ejd��ej
d�eedd�dd�d�d��ej
d�d7d�d�ej
d�eedd��dd2ejd��e	�d�d��Zej
d�ed�dG�ej
d�d�eed�dtd�d�d��ej
d�dd�gd�d��ej
d�d�ed�edd��d�d��ej
d�d�ed�edd{�d�d��ej
d�d�d�d�gd�d�d$�ej
d�d�eed�d�d�d��ej
d�d�eedd��d�d�d��ej
d�d�d�d�gd�d�d$�ej
d�d(d�d�ej
d�d(d�d�ej
d�eed�d�d�d�d��e	�d�d��Zej
d�d�d7d�d�ej
d�eejdG�dS)��N�)�PROGRAM_NAME)�__version__csD�dk	r���nd��dk	r$���nd����fdd�}�j|_|S)zValidator for numeric paramsNcsF�|�}�dk	r|�ks(�dk	rB|�krBd|��ff}t�|��|S)Nz%r not in valid range %r)�argparseZArgumentTypeError)�string�value�msg��basetype�max_�min_��./usr/lib/python3/dist-packages/ocrmypdf/cli.py�_numerics
 
znumeric.<locals>._numeric)�__name__)r
rrrr
r	r�numerics
rcs,eZdZdZ�fdd�Z�fdd�Z�ZS)�ArgumentParserz�Override parser's default behavior of calling sys.exit()

    https://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code
    cst�j||�d|_dS)NF)�super�__init__�api_mode)�self�args�kwargs��	__class__r
rr.szArgumentParser.__init__cs"|jst��|�dSt|��dS)N)rr�error�
ValueError)r�messagerr
rr2szArgumentParser.error)r�
__module__�__qualname__�__doc__rr�
__classcell__r
r
rrr(sr�@aGenerates a searchable PDF or PDF/A from a regular PDF.

OCRmyPDF rasterizes each page of the input PDF, optionally corrects page
rotation and performs image processing, runs the Tesseract OCR engine on the
image, and then creates a PDF from the OCR information.
aXOCRmyPDF attempts to keep the output file at about the same size.  If a file
contains losslessly compressed images, and output file will be losslessly
compressed as well.

PDF is a page description file that attempts to preserve a layout exactly.
A PDF can contain vector objects (such as text or lines) and raster objects
(images).  A page might have multiple images.  OCRmyPDF is prepared to deal
with the wide variety of PDFs that exist in the wild.

When a PDF page contains text, OCRmyPDF assumes that the page has already
been OCRed or is a "born digital" page that should not be OCRed.  The default
behavior is to exit in this case without producing a file.  You can use the
option --skip-text to ignore pages with text, or --force-ocr to rasterize
all objects on the page and produce an image-only PDF as output.

    ocrmypdf --skip-text file_with_some_text_pages.pdf output.pdf

    ocrmypdf --force-ocr word_document.pdf output.pdf

If you are concerned about long-term archiving of PDFs, use the default option
--output-type pdfa which converts the PDF to a standardized PDF/A-2b.  This
converts images to sRGB colorspace, removes some features from the PDF such
as Javascript or forms. If you want to minimize the number of changes made to
your PDF, use --output-type pdf.

If OCRmyPDF is given an image file as input, it will attempt to convert the
image to a PDF before processing.  For more control over the conversion of
images to PDF, use img2pdf, or other image to PDF software.

For example, this command uses img2pdf to convert all .png files beginning
with the 'page' prefix to a PDF, fitting each image on A4-sized paper, and
sending the result to OCRmyPDF through a pipe.

    img2pdf --pagesize A4 page*.png | ocrmypdf - myfile.pdf

HTML documentation is located at:
    /usr/share/doc/ocrmypdf/html/index.html
after installing the ocrmypdf-doc package.

)�progZfromfile_prefix_charsZformatter_classZdescriptionZepilogZ
input_fileZinput_pdf_or_imagezOPDF file containing the images to be OCRed (or '-' to read from standard input))�metavar�helpZoutput_fileZ
output_pdfz�Output searchable PDF file (or '-' to write to standard output). Existing files will be ovewritten. If same as input file, the input file will be updated only if processing is successful.z-lz
--language�appendz�Language(s) of the file to be OCRed (see tesseract --list-langs for all language packs installed in your system). Use -l eng+deu for multiple languages.)�actionr%z--image-dpiZDPIz?For input image instead of PDF, use this DPI instead of file's.)r$�typer%z
--output-typeZpdfaZpdfzpdfa-1zpdfa-2zpdfa-3a�Choose output type. 'pdfa' creates a PDF/A-2b compliant file for long term archiving (default, recommended) but may not suitable for users who want their file altered as little as possible. 'pdfa' also has problems with full Unicode text. 'pdf' attempts to preserve file contents as much as possible. 'pdf-a1' creates a PDF/A1-b file. 'pdf-a2' is equivalent to 'pdfa'. 'pdf-a3' creates a PDF/A3-b file.)�choices�defaultr%z	--sidecar�?�ZFILEamGenerate sidecar text files that contain the same text recognized by Tesseract. This may be useful for building a OCR text database. If FILE is omitted, the sidecar file be named {output_file}.txt If FILE is set to '-', the sidecar is written to stdout (a convenient way to preview OCR quality). The output file and sidecar may not both use stdout at the same time.)�nargs�constr*r$r%z	--version�versionzPrint program version and exit)r'r/r%zJob control optionsz-jz--jobs�N�z8Use up to N CPU cores simultaneously (default: use all).z-qz--quiet�
store_truezSuppress INFO messagesz-vz	--verbose�z�Print more verbose messages for each additional verbose level. Use `-v 1` typically for much more detailed logging. Higher numbers are probably only useful in debugging.)r(r*r.r-r%z--no-progress-barZstore_falseZprogress_bar)r'�destr%z
--use-threadszMetadata optionszCSet output PDF/A metadata (default: copy input document's metadata)z--titlez3Set document title (place multiple words in quotes))r(r%z--authorzSet document authorz	--subjectz Set document subject descriptionz
--keywordszSet document keywordszImage preprocessing optionsz7Options to improve the quality of the final PDF and OCRz-rz--rotate-pagesz=Automatically rotate pages based on detected text orientationz--remove-backgroundzKAttempt to remove background from gray or color pages, setting it to white z-dz--deskewz&Deskew each page before performing OCRz-cz--cleanz�Clean pages from scanning artifacts before performing OCR, and send the cleaned page to OCR, but do not include the cleaned page in the outputz-iz
--clean-finalzgClean page as above, and incorporate the cleaned image in the final PDF.  Might remove desired content.z--unpaper-argszmA quoted string of arguments to pass to unpaper. Requires --clean. Example: --unpaper-args '--layout double'.)r(r*r%z--oversamplei�zPOversample images to at least the specified DPI, to improve OCR results slightly)r$r(r*r%z--remove-vectorsz�EXPERIMENTAL. Mask out any vector objects in the PDF so that they will not be included in OCR. This can eliminate false characters.z--thresholdz�EXPERIMENTAL. Threshold image to 1bpp before sending it to Tesseract for OCR. Can improve OCR quality compared to Tesseract's thresholder.zOCR optionszControl how OCR is appliedz-fz--force-ocrzrRasterize any text or vector objects on each page, apply OCR, and save the rastered output (this rewrites the PDF)z-sz--skip-textz�Skip OCR on any pages that already contain text, but include the page in final output; useful for PDFs that contain a mix of images, text pages, and/or previously OCRed pagesz
--redo-ocraAttempt to detect and remove the hidden OCR layer from files that were previously OCRed with OCRmyPDF or another program. Apply OCR to text found in raster images. Existing visible text objects will not be changed. If there is no existing OCR, OCR will be added.z
--skip-bigZMPixelszkSkip OCR on pages larger than the specified amount of megapixels, but include skipped pages in final output)r(r$r%zOptimization optionsz*Control how the PDF is optimized after OCRz-Oz
--optimize�z�Control how PDF is optimized after processing:0 - do not optimize; 1 - do safe, lossless optimizations (default); 2 - do some lossy optimizations; 3 - do aggressive lossy optimizations (including lossy JBIG2))r(r)r*r%z--jpeg-quality�d�Qz�Adjust JPEG quality level for JPEG optimization. 100 is best quality and largest output size; 1 is lowest quality and smallest output; 0 uses the default.)r(r*r$r%z
--jpg-qualityZjpeg_quality)r(r*r$r4r%z
--png-qualityzeAdjust PNG quality level to use when quantizing PNGs. Values have same meaning as with --jpeg-qualityz
--jbig2-lossyzbEnable JBIG2 lossy mode (better compression, not suitable for some use cases - see documentation).z--jbig2-page-group-sizei'ZAdvancedz4Advanced options to control Tesseract's OCR behaviorz--pageszMLimit OCR to the specified pages (ranges or comma separated), skipping othersz--max-image-mpixelsZstorezWSet maximum number of pixels to unpack before treating an image as a decompression bombg`@)r'r(r$r%r*z--tesseract-configZCFGz=Additional Tesseract configuration files -- see documentation)r'r$r*r%z--tesseract-pagesegmodeZPSM�z;Set Tesseract page segmentation mode (see tesseract --help))r'r(r$r)r%z--tesseract-oemZMODEz}Set Tesseract 4.0 OCR engine mode: 0 - original Tesseract only; 1 - neural nets LSTM only; 2 - Tesseract + LSTM; 3 - default.z--pdf-renderer�autoZhocrZsandwichzjChoose OCR PDF renderer - the default option is to let OCRmyPDF choose.  See documentation for discussion.z--tesseract-timeoutg�f@ZSECONDSzVGive up on OCR after the timeout, but copy the preprocessed page into the final output)r*r(r$r%z--rotate-pages-thresholdg,@i�Z
CONFIDENCEz]Only rotate pages when confidence is above this value (arbitrary units reported by tesseract)z--pdfa-image-compressionZjpegZlosslessa�Specify how to compress images in the output PDF/A. 'auto' lets OCRmyPDF decide.  'jpeg' changes all grayscale and color images to JPEG compression.  'lossless' uses PNG-style lossless compression for all images.  Monochrome images are always compressed using a lossless codec.  Compression settings are applied to all pages, including those for which OCR was skipped.  Not supported for --output-type=pdf ; that setting preserves the original compression of all images.z--user-wordsaSpecify the location of the Tesseract user words file. This is a list of words Tesseract should consider while performing OCR in addition to its standard language dictionaries. This can improve OCR quality especially for specialized and technical documents.z--user-patternsz9Specify the location of the Tesseract user patterns file.z--fast-web-viewg�?Z	MEGABYTESa~If the size of file is more than this threshold (in MB), then linearize the PDF for fast web viewing. This allows the PDF to be displayed before it is fully downloaded in web browsers, but increases the space required slightly. By default we skip this for small files which do not benefit. If the threshold is 0 it will be apply to all files. Set the threshold very high to disable.Z	Debuggingz4Arguments to help with troubleshooting and debuggingz-kz--keep-temporary-filesz,Keep temporary files (helpful for debugging)z--tesseract-env)NN)rZ_versionrZ
_PROGRAM_NAMErZ_VERSIONrrZRawDescriptionHelpFormatter�parser�add_argument�intZadd_argument_groupZ
jobcontrolZSUPPRESSZmetadata�strZ
preprocessingZocrsettings�floatZ
optimizing�rangeZadvancedZ	debuggingr
r
r
r�<module>sv
�6�������

��
�����������
������
���
�
�
�
�
�	���	�����
��
���
��