This commit is contained in:
John Whitington 2019-08-05 12:35:07 +01:00
parent ae113db050
commit 0c806b21cd
3 changed files with 24 additions and 18 deletions

View File

@ -1029,9 +1029,9 @@ let parse_rectangle pdf s =
try try
match parse_units_string pdf emptypage s with match parse_units_string pdf emptypage s with
| [x; y; w; h] -> x, y, w, h | [x; y; w; h] -> x, y, w, h
| _ -> error "Bad rectangle specification" | _ -> error ("Bad rectangle specification " ^ s)
with with
_ -> error "Bad rectangle specification" _ -> error ("Bad rectangle specification " ^ s)
let parse_rectangles pdf s = let parse_rectangles pdf s =
try try
@ -1040,18 +1040,18 @@ let parse_rectangles pdf s =
List.map List.map
(function (function
| [x; y; w; h] -> (x, y, w, h) | [x; y; w; h] -> (x, y, w, h)
| _ -> error "Bad rectangle specification") | _ -> error ("Bad rectangle specification " ^ s))
groups groups
with with
_ -> error "Bad rectangle specification" _ -> error ("Bad rectangle specification " ^ s)
let parse_coordinate pdf s = let parse_coordinate pdf s =
try try
match parse_units_string pdf emptypage s with match parse_units_string pdf emptypage s with
| [dx; dy] -> dx, dy | [dx; dy] -> dx, dy
| _ -> error "Bad coordinate specification" | _ -> error ("Bad coordinate specification " ^ s)
with with
_ -> error "Bad coordinate specification" _ -> error ("Bad coordinate specification " ^ s)
let parse_coordinates pdf s = let parse_coordinates pdf s =
try try
@ -1060,18 +1060,18 @@ let parse_coordinates pdf s =
List.map List.map
(function (function
| [dx; dy] -> (dx, dy) | [dx; dy] -> (dx, dy)
| _ -> error "Bad coordinate specification") | _ -> error ("Bad coordinate specification " ^ s))
groups groups
with with
_ -> error "Bad coordinate specification" _ -> error ("Bad coordinate specification " ^ s)
let parse_single_number pdf s = let parse_single_number pdf s =
try try
match parse_units_string pdf emptypage s with match parse_units_string pdf emptypage s with
| [x] -> x | [x] -> x
| _ -> error "Bad number Argument" | _ -> error ("Bad number argument " ^ s)
with with
_ -> error "Bad number argument" _ -> error ("Bad number argument " ^ s)
(* Setting operations *) (* Setting operations *)
let setcrop s = let setcrop s =
@ -4654,6 +4654,11 @@ let go_withargv argv =
args.path_to_ghostscript <- gslocation; args.path_to_ghostscript <- gslocation;
ignore (gs_malformed_force inputfilename outputfilename); ignore (gs_malformed_force inputfilename outputfilename);
exit 0 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; Hashtbl.clear filenames;
if demo then if demo then

Binary file not shown.

View File

@ -215,8 +215,8 @@ after any range). The document will \textit{not} be re-encrypted upon writing.
example: example:
\begin{framed} \begin{framed}
\noindent\small\verb!cpdf in.pdf user=charles -info!\\ \small\verb!cpdf in.pdf user=charles -info!\\
\noindent\small\verb!cpdf in.pdf owner=fred reverse -o out.pdf! \indent\small\verb!cpdf in.pdf owner=fred reverse -o out.pdf!
\end{framed} \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: \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): progress is shown on \verb!stderr! (Standard Error):
\begin{framed} \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!couldn't lex object number!\\
\small\verb!Attempting to reconstruct the malformed pdf in.pdf...!\\ \small\verb!Attempting to reconstruct the malformed pdf in.pdf...!\\
\small\verb!Read 5530 objects!\\ \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: \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} \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} \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. \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 Sometimes files can be technically well-formed but use inefficient PDF
constructs. If you are sure the input files you are using are 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} \begin{framed}
\small\verb?cpdf -create-pdf -create-pdf-pages 20?\\ \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} \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. \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.