
    h42              	          S SK r S SKrS SKrS SKrS SKJr  S SK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JrJrJrJr  \R6                  " \5      rS r\" \R@                  RB                  \R@                  RD                  \RF                  " \R@                  RD                  SS9\S9r$Sr%\" S	S
\&S9r'\" SSSSS9r(S r) " S S5      r* " S S\*5      r+ " S S\*5      r,S r-S r.S r/S r0g! \ a    Sr Nf = f)    N)Path)	add_input	get_inputsetup_loggingBooleanOptionalActionc                     U[         R                  :X  a  SnO7U[         R                  :X  a  SnO [        S[        R
                  U    S35      e[        R                  R                  " XU/UQ70 UD6$ )NFTz5Cannot create foreign_simple bitmap with bitmap type .)	pdfium_rFPDFBitmap_BGRxFPDFBitmap_BGRARuntimeErrorpdfium_iBitmapTypeToStrpdfium	PdfBitmapnew_foreign_simple)widthheightformatargskwargs	use_alphas         M/var/www/html/shao/venv/lib/python3.13/site-packages/pypdfium2/_cli/render.py_bitmap_wrapper_foreign_simpler      sp    )))		8++	+	RS[SkSklrSsRttuvww..uiY$YRXYY    T)force_packed)nativeforeignforeign_packedforeign_simple)	path_fillpath_stroke	text_filltext_strokeC   )metavarnargstype)   d   r      )r      r,   r,   r,   r,   r,   r,   )r-   r,   r   r,   c           	         [        U SS9  U R                  SS[        SSS9  U R                  SSS	9  U R                  S
SS[        R                  SS9  U R                  SSS SS9  U R                  SS[
        SS9  U R                  SS[        SSS9  U R                  "  S`SS0[        D6  U R                  SSS S!9  U R                  S"S#[
        S$S%S&9  U R                  S'[        SS(S)9  U R                  S*[        SS+S)9  U R                  S,S-/ S.[        R                  S/S09  U R                  S1S2S3S49  U R                  S5S6S79nUR                  S8[        R                  5       S9S:[        R                  S;9  UR                  S<S2S=S49  UR                  S>S?S@ SAS9  UR                  SBSC[        SDSE9  U R                  SFSGS79nUR                  SHSI[        [        R                  SJSK9  UR                  SL[        R                  " 5       [        SMS9  UR                  SNSOSP[        R                  SQSR9  UR                  SSSTSU[        R                  SVSR9  UR                  SW[        R                  SXSY9  U R                  SZS[S79nUR                  S\S2S]S49  UR                  "  Sa0 [        D6  UR                  "  Sb0 [        D6  UR                  "  Sc0 [        D6  UR                  "  Sd0 [        D6  UR                  S^S2S_S49  g )eNT)pagesz--outputz-ozDOutput directory where the serially numbered images shall be placed.)r)   requiredhelpz--prefixzDCustom prefix for the images. Defaults to the input filename's stem.)r2   z--formatz-fjpgzThe image format to use.)defaultr)   r2   z--engine
engine_clsc                 >    [         [        S.U R                  5          $ )N)pilz	numpy+cv2)	PILEngineNumpyCV2Enginelower)ks    r   <lambda>attach.<locals>.<lambda>M   s    HSr   z(The saver engine to use (pil, numpy+cv2))destr)   r2   z--scale   zDefine the resolution of the output images. By default, one PDF point (1/72in) is rendered to 1x1 pixel. This factor scales the number of pixels that represent one point.z
--rotationr   )r   Z      i  z'Rotate pages by 90, 180 or 270 degrees.)r4   r)   choicesr2   r2   zColor the bitmap will be filled with before rendering. It shall be given in RGBA format as a sequence of integers ranging from 0 to 255. Defaults to white.z--optimize-mode)lcdprintz3The rendering optimisation mode. None if not given.)rB   r2   z--cropr&   )r   r   r   r   z/Amount to crop from (left, bottom, right, top).)r(   r)   r4   r2   z--draw-annotsz1Whether annotations may be shown (default: true).)actionr4   r2   z--draw-formsz+Whether forms may be shown (default: true).z--no-antialias+)textimagepathz&Item types that shall not be smoothed.)r(   r4   rB   r)   r2   z--force-halftone
store_truez)Always use halftone for image stretching.)rE   r2   zBitmap optionsz&Bitmap config, including pixel format.)titledescriptionz--bitmap-makerr   zThe bitmap maker to use.)rB   r4   r2   r)   z--grayscalez0Whether to render in grayscale mode (no colors).z--byteorderrev_byteorderc                 .    SSS.U R                  5          $ )NFT)bgrrgb)r:   )vs    r   r<   r=      s    t4QWWY?r   z;Whether to use BGR or RGB byteorder (default: conditional).z--x-channelprefer_bgrxz@Whether to prefer BGRx/RGBx over BGR/RGB (default: conditional).)r>   rE   r2   Parallelizationz.Options for rendering with multiple processes.z--linear?zRender non-parallel if page count is less or equal to the specified value (default is conditional). If this flag is given without a value, then render linear regardless of document length.)r(   r)   constr2   z--processeszXThe maximum number of parallel rendering processes. Defaults to the number of CPU cores.z--parallel-strategy)spawn
forkserverforkrV   zQThe process start method to use. ('fork' is discouraged due to stability issues.))rB   r4   r)   r2   z--parallel-libmpftrZ   zRThe parallelization module to use (mp = multiprocessing, ft = concurrent.futures).z--parallel-mapzLThe map function to use (backend specific, the default is an iterative map).)r)   r2   zForced color schemez[Options for using pdfium's forced color scheme renderer. Deprecated, considered not useful.z--sample-themezWUse a dark background sample theme as base. Explicit color params override selectively.z--fill-to-strokezqOnly draw borders around fill areas using the `path_stroke` color, instead of filling with the `path_fill` color.)z--fill-color)z--path-fill)z--path-stroke)z--text-fill)z--text-stroke)r   add_argumentr   strr:   floatint	ColorOptsr   add_argument_groupBitmapMakerskeysmathinfos	cpu_count)parserbitmapparallelcolor_schemes       r   attachrl   8   s$   fD!
DU	   U   Dyy)	   S9	    |	   #8    m 
 "D  
 @   &B	   &<	   +yy7   :   && > ' F ##%)yy   A  
 ?L	   &Q	   ((!F ) H  N   ,,.i	   1yyb   yyc   yy]   ,,%s - L h  
 
 
 
 
  C  r   c                   &    \ rS rSrS rS rS rSrg)SavingEngine   c                     Xl         g N_path_parts)self
path_partss     r   __init__SavingEngine.__init__   s    %r   c                 F    U R                   u  p#pEX# US-   SU S3 SU 3-  $ )Nr?   0dr	   rr   )rt   i
output_dirprefixn_digitsr   s         r   	_get_pathSavingEngine._get_path   s9    /3/?/?,
Hhqs1XJa-&8&BBBr   c                     U R                  U5      nU R                  X15        [        R                  SUS-    SUR                   35        g )NzWrote page r?   z as )r   _saving_hookloggerinfoname)rt   ri   r{   out_paths       r   __call__SavingEngine.__call__   s?    >>!$(+k!A#d8==/:;r   rr   N)__name__
__module____qualname____firstlineno__rv   r   r   __static_attributes__ r   r   rn   rn      s    &C<r   rn   c                       \ rS rSrS rSrg)r8      c                 B    UR                  5       R                  U5        g rq   )to_pilsavert   r   ri   s      r   r   PILEngine._saving_hook   s    X&r   r   Nr   r   r   r   r   r   r   r   r   r8   r8      s    'r   r8   c                       \ rS rSrS rSrg)r9      c                 `    [         R                  " [        U5      UR                  5       5        g rq   )cv2imwriter]   to_numpyr   s      r   r   NumpyCV2Engine._saving_hook   s    CM6??#45r   r   Nr   r   r   r   r9   r9      s    6r   r9   c                     U (       a  U " 5         [         R                  S[        R                  " 5        35        [        R
                  " XSS9nU(       a  UR                  5         XdU4qg )NzInitializing data for process T)password	autoclose)r   r   rf   getpidr   PdfDocument
init_formsProcObjs)
extra_initinputr   may_init_formsr   enginepdfs          r   _render_parallel_initr     sO    
KK0>?


U
FC V$Hr   c                 @    X   nUR                   " S0 UD6nU" XP5        g )Nr   )render)r{   r   r   r   pageri   s         r   _render_jobr     s"    6D[["6"F
6r   c                 $    [        U /[        Q76   g rq   )r   r   )r{   s    r   _render_parallel_jobr     s     .X.r   c                 
  ^ [        X R                  S9n[        U5      m[        U4S jU R                   5       5      (       d  [        S5      e[        U R                  5      [        [        U R                  5      5      :w  a  [        S5      eU R                  c  U R                  R                   S3U l        U R                  c  U R                  (       a  SOSU l
        U R                  c  U R                  S:X  a  S	OS
U l        U R                  c1  [        S :w  a  U R                  S:X  a  [         U l        O["        U l        U R$                  c  U R                  ["        L U l        U R&                  c-  U R                  ["        L =(       a    U R                  S:g  U l        [)        5       nU R                  (       a  UR*                  " S0 [,        D6  UR*                  " S0 [.         Vs0 sH!  n[1        X5      (       d  M  U[1        X5      _M#     snD6  [        U5      S:  a  [2        R4                  " S0 UD6OS n[)        U R6                  U R8                  U R:                  U R<                  U R                  UU R>                  U R@                  U RB                  U R                  U RD                  U R$                  U R&                  [F        U RH                     S9nU RJ                   H  nSUSU 3'   M     [L        RO                  U R                  RP                   SU R                   SU R$                   SU R&                   35        [        [S        T5      5      nU RT                  U R                  XpR                  4nU R                  U5      n	[        U R                  5      U R                  ::  a5  [L        RO                  S5        U R                   H  n
[W        XXY5        M     g [L        RO                  S5        [X        RZ                  " U R\                  5      n[)        UR^                  S4[`        Rb                  " [d        Rf                  US9S4S9nXRh                     u  pU Rj                  (       a  U Rj                  nU R\                  S;   a  [l        OS n[)        [n        XRp                  U Rr                  U R                  XY4S9n[u        U Rv                  [        U R                  5      5      nU" U40 UD6 n[1        UU5      nU" [x        U R                  5       H  nM     S S S 5        g s  snf ! , (       d  f       g = f)N)r   c              3   L   >#    U H  nS Us=:*  =(       a    T:  Os  v   M     g7f)r   Nr   ).0r{   pdf_lens     r   	<genexpr>main.<locals>.<genexpr>#  s!     4AqAs   !$z*Out-of-bounds page indices are prohibited.z&Duplicate page indices are prohibited._)r   r   r   r,   r.   r3         pngr   )scalerotationcrop	grayscale
fill_colorrk   fill_to_strokeoptimize_modedraw_annotsmay_draw_formsforce_halftonerM   rR   bitmap_makerT	no_smoothz
, Format: z, rev_byteorder: z, prefer_bgrx zLinear rendering ...zParallel rendering ...imap)
mp_contextmaprY   )rV   rW   )initializerinitargsr   )=r   
draw_formslenallr0   
ValueErrorsetr}   r   stemr   sample_themelinearr   r5   r   r9   r8   rM   rR   dictupdateSampleThemeCsFieldsgetattrr   PdfColorSchemer   r   r   r   r   r   r   r   rb   r   no_antialiasr   r   r   r]   outputr   rZ   get_contextparallel_strategyPool	functoolspartialr[   ProcessPoolExecutorparallel_libparallel_mapr   r   _inputr   min	processesr   )r   r   	cs_kwargsfcsr   r)   r~   ru   r   r{   ctxpool_backends	pool_ctormap_attrr   pool_kwargsn_procspoolmap_funcr   r   s                        @r   mainr     s0    D__
5C #hG4444EFF
4::#c$**o..ABB{{)+,0,=,=.CW{{;;%/aQ $;4;;%/,DO'DO !!__	9??i7PDKK5<PI';'SXRXAQ+74++XRS/29~/A			+	+tB

==yyNN__,,**&&,,**&&#D$5$56F  !!%)4&!" " KK4??++,Jt{{mCTUYUgUgThhvw{  xH  xH  wI  J  K3w< H++t{{HkkBJ__Z(F
4::$++%*+A/ 
 	,-nnT334((F###B$:$:sKUS
 ,,=,=>	((H'+'='=AX'Xm^b
/"JJtPV_

 dnnc$**o6w.+.$tX.H2DJJ? @ /.q Sp /.s   *T2T2>+T77
U)1rf   rd   loggingr   pathlibr   multiprocessingrZ   concurrent.futuresfuturesr[   r   ImportErrorpypdfium2._helpers_helpersr   pypdfium2.internalinternalr   pypdfium2.rawrawr
   pypdfium2._cli._parsersr   r   r   r   	getLoggerr   r   r   r   r   
new_nativenew_foreignr   rb   r   r_   r`   r   rl   rn   r8   r9   r   r   r   r   r   r   r   <module>r     s   
       $ %    
		8	$Z ((**&&v'7'7'C'CRVW3	 DAC0	&&&&od< <' '6l 6
%/`[  
Cs   C0 0C;:C;