From 274d580f9859ae3761c01a50431a411e2dd39c2b Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 23 Sep 2014 19:18:54 +0100 Subject: [PATCH] Documentation for -squeeze --- cpdfcommand.ml | 36 ++++++++++++++++++++++-------------- cpdfmanual.pdf | Bin 206158 -> 206759 bytes cpdfmanual.tex | 15 +++++++++++++-- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 5769cd3..c4bfa8a 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1826,22 +1826,30 @@ let squeeze_all_content_streams pdf = Some d -> d | None -> Pdf.Dictionary [] in - let newstream = - match lookup "/Contents" dict with - Some (Pdf.Indirect i) -> + begin try + let newstream = + let content_streams = + match lookup "/Contents" dict with + Some (Pdf.Indirect i) -> + begin match Pdf.direct pdf (Pdf.Indirect i) with + Pdf.Array x -> x + | _ -> [Pdf.Indirect i] + end + | Some (Pdf.Array x) -> x + | _ -> raise Not_found + in Pdfops.stream_of_ops - (Pdfops.parse_operators pdf resources [Pdf.Indirect i]) - | Some (Pdf.Array x) -> - Pdfops.stream_of_ops - (Pdfops.parse_operators pdf resources x) - | _ -> - raise (Pdf.PDFError "squeeze_all_content_streams") - in - let newdict = - Pdf.add_dict_entry - d "/Contents" (Pdf.Indirect (Pdf.addobj pdf newstream)) + (Pdfops.parse_operators pdf resources content_streams) in - Pdf.addobj_given_num pdf (objnum, newdict) + let newdict = + Pdf.add_dict_entry + d "/Contents" (Pdf.Indirect (Pdf.addobj pdf newstream)) + in + Pdf.addobj_given_num pdf (objnum, newdict) + with + (* No /Contents, which is ok. *) + Not_found -> () + end | _ -> ()) pdf diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index b2aba40e63f4dddb8c9a2bd4957964516207a5e3..4dbc0725abe22aa026635dd0a0d4d33c96ed6b9e 100644 GIT binary patch delta 5263 zcmV;A6maX#$_%H^46rkq0x&d}alry9f3;W3ZsRr--TN!Js|>^(z8_s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MzR z4}DQxQZU&!A~<((sy=WfuKgUJB0DpzMF7G}#sK$})Py?0G$~#iR_nE16_Ctf$h^rB zt+Wlib@-4Q??uQg+2FRCU;5^U$->{k^XgM?S*?zYv?NBSrgn?<+uDq8sA=UsiyXS- z)t}7#lenH5dQ6{71uZOZY&xn{M-`L&e2dc0J4JI0AdoM{+&3Cc9i25lTeAjB0k7a$ zGI(@2E!#h-c9#w5?)n;({p`xNf2_|2?P}cBr`6@H;~obYlvyWGMy|y`^cNA1Y+MT9 zwsNa8^P=>As;?x>sa@j|QRn2Ttc|H%s<->SjK|+sReZBPyXtPjgdy$fT{mcR+zR;W z`fW0giz=s}g`yp(4Y9n~3L_^=!1&YA+gFa81Maolsi8+2^;s9KQBuQq6s0@Qec`kg zyu_OaWD;H>_KIxp6L5Gsbr}0>s@g@3d3|%jNB0!>7f;X^zt-IoqROQwGIFk((?8`| zS))t3Ssed*tjk=u_9*jW-=|6MTh*9_Txnai-`VcH@o=upPl%QhBRlq=fXZ^)!SSR zC`Dz7<`H&RYctn?dC%fXAd(wzOF#{DiS`$#xOsnaQM`Ioe;%_|5RLkgmQ~9a-mbQx%rB>YI0K%YF|%=bA?&<#ddB07tzUdHF1fmP zxkFS~swz=LL9e6q?&wR+@bBe^R!P%q!NA$m#%Xr;BQw!nC7`a%7UgsG*r*0|y)i!S zUFCOSVB}>UNUY4AsX6fQDxGjhd9V2A3$JnSC|A^kydnR`Pq|)~yN%Qv+Cd4gbY&a( zH#E)?Z#pw@s?!Pd;z7_@9!)yI=tKws1bxS&Rf&fXlzmBHZypLH;aQ;Z!vc+X`s^S6 h^l3QQ3HlE}*6xEy3l$^fqn3loDNu=sXc=i!{SP3A+ZzA? diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 9ba64ff..80115e4 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -943,12 +943,23 @@ PDF, use: \section{Squeezing a Document} \index{squeeze} - To \textit{squeeze} a PDF file, use: + To \textit{squeeze} a PDF file, reducing its size by an average of about twenty percent (though sometimes not at all), use: \begin{framed} \small\verb!cpdf -squeeze in.pdf -o out.pdf! \end{framed} - \noindent Adding \texttt{-squeeze} to the command line will \textit{squeeze} the file upon output. The squeezing process involves several processes which losslessly attempt to reduce the file size. The squeezing process is slow. + \noindent Adding \texttt{-squeeze} to the command line when using another operation will \textit{squeeze} the file or files upon output. + The \texttt{-squeeze} operation writes some information about the squeezing process to standard output. The squeezing process involves several processes which losslessly attempt to reduce the file size. It is slow, so should not be used without thought. + +\begin{verbatim} +$ ./cpdf -squeeze in.pdf -o out.pdf +Beginning squeeze: 123847 objects +Squeezing... Down to 114860 objects +Squeezing... Down to 114842 objects +Squeezing page data +Recompressing document +\end{verbatim} + \chapter{Bookmarks} \begin{framed} \small\noindent\verb!cpdf -list-bookmarks [-utf8 | -raw] in.pdf!