diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 39a9bd2..a5578d8 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1029,9 +1029,9 @@ let parse_rectangle pdf s = try match parse_units_string pdf emptypage s with | [x; y; w; h] -> x, y, w, h - | _ -> error "Bad rectangle specification" + | _ -> error ("Bad rectangle specification " ^ s) with - _ -> error "Bad rectangle specification" + _ -> error ("Bad rectangle specification " ^ s) let parse_rectangles pdf s = try @@ -1040,18 +1040,18 @@ let parse_rectangles pdf s = List.map (function | [x; y; w; h] -> (x, y, w, h) - | _ -> error "Bad rectangle specification") + | _ -> error ("Bad rectangle specification " ^ s)) groups with - _ -> error "Bad rectangle specification" + _ -> error ("Bad rectangle specification " ^ s) let parse_coordinate pdf s = try match parse_units_string pdf emptypage s with | [dx; dy] -> dx, dy - | _ -> error "Bad coordinate specification" + | _ -> error ("Bad coordinate specification " ^ s) with - _ -> error "Bad coordinate specification" + _ -> error ("Bad coordinate specification " ^ s) let parse_coordinates pdf s = try @@ -1060,18 +1060,18 @@ let parse_coordinates pdf s = List.map (function | [dx; dy] -> (dx, dy) - | _ -> error "Bad coordinate specification") + | _ -> error ("Bad coordinate specification " ^ s)) groups with - _ -> error "Bad coordinate specification" + _ -> error ("Bad coordinate specification " ^ s) let parse_single_number pdf s = try match parse_units_string pdf emptypage s with | [x] -> x - | _ -> error "Bad number Argument" + | _ -> error ("Bad number argument " ^ s) with - _ -> error "Bad number argument" + _ -> error ("Bad number argument " ^ s) (* Setting operations *) let setcrop s = @@ -4654,6 +4654,11 @@ let go_withargv argv = args.path_to_ghostscript <- gslocation; ignore (gs_malformed_force inputfilename outputfilename); exit 0 + | [|_; inputfilename; "-gs"; gslocation; "-gs-malformed-force"; "-o"; outputfilename; "-gs-quiet"|] -> + args.path_to_ghostscript <- gslocation; + args.gs_quiet <- true; + ignore (gs_malformed_force inputfilename outputfilename); + exit 0 | _ -> Hashtbl.clear filenames; if demo then diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 9389ee7..38a2235 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index e5e9304..e5e5dce 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -215,8 +215,8 @@ after any range). The document will \textit{not} be re-encrypted upon writing. example: \begin{framed} -\noindent\small\verb!cpdf in.pdf user=charles -info!\\ -\noindent\small\verb!cpdf in.pdf owner=fred reverse -o out.pdf! +\small\verb!cpdf in.pdf user=charles -info!\\ +\indent\small\verb!cpdf in.pdf owner=fred reverse -o out.pdf! \end{framed} \noindent To re-encrypt the file with its existing encryption upon writing, which is required if only the user password was supplied, but allowed in any case, add the \texttt{-recrypt} option: @@ -436,7 +436,7 @@ Grossly malformed files will be reconstructed. The reconstruction progress is shown on \verb!stderr! (Standard Error): \begin{framed} -\noindent\small\verb!./cpdf in.pdf -o out.pdf!\\ +\noindent\small\verb!$cpdf in.pdf -o out.pdf!\\ \small\verb!couldn't lex object number!\\ \small\verb!Attempting to reconstruct the malformed pdf in.pdf...!\\ \small\verb!Read 5530 objects!\\ @@ -446,16 +446,17 @@ progress is shown on \verb!stderr! (Standard Error): \noindent If \texttt{cpdf} cannot reconstruct a malformed file, it is able to use the \texttt{gs} program to try to reconstruct the program, if you have it installed. For example, if \texttt{gs} is installed and in your path, we might try: \begin{framed} -\noindent\small\verb!./cpdf -gs gs -gs-malformed in.pdf -o out.pdf!\end{framed} +\noindent\small\verb!cpdf -gs gs -gs-malformed in.pdf -o out.pdf!\end{framed} -\noindent If the malformity lies inside an individual page of the PDF, rather than in its gross structure, cpdf may appear to succeed in reconstruction, only to fail when processing a page (e.g when adding text). To force the use of \texttt{gs} to pre-process such files so cpdf cannot fail on them, use \texttt{-gs-malformed-force}: +\noindent If the malformity lies inside an individual page of the PDF, rather than in its gross structure, cpdf may appear to succeed in reconstruction, only to fail when processing a page (e.g when adding text). To suppress the output of \texttt{gs} use the \texttt{-gs-quiet} option. + +To force the use of \texttt{gs} to pre-process such files so cpdf cannot fail on them, use \texttt{-gs\--malformed\--force}: \begin{framed} -\noindent\small\verb!./cpdf -gs gs -gs-malformed-force in.pdf -o out.pdf!\end{framed} +\noindent\small\verb!cpdf -gs gs -gs-malformed-force in.pdf -o out.pdf [-gs-quiet]!\end{framed} \noindent The command line for \texttt{-gs-malformed-force} must be of \textit{precisely} this form. -To suppress the output of \texttt{gs} use the \texttt{-gs-quiet} option. Sometimes files can be technically well-formed but use inefficient PDF constructs. If you are sure the input files you are using are @@ -565,7 +566,7 @@ Cpdf can build a new PDF file, given a number of pages and a paper size. The def \begin{framed} \small\verb?cpdf -create-pdf -create-pdf-pages 20?\\ - \small\verb? -create-pdf-papersize usletter -o out.pdf? + \noindent\small\verb? -create-pdf-papersize usletterportrait -o out.pdf? \end{framed} \noindent The standard paper sizes are listed in Section \ref{papersizes}, or you may specify the width and height directly, as described in the same Chapter.