Fix -squeeze treatment of -no-pagedata and -no-recompress

This commit is contained in:
John Whitington 2023-02-03 12:13:55 +00:00
parent 214e3c3fa2
commit 496d10dea2
3 changed files with 8 additions and 3 deletions

Binary file not shown.

View File

@ -1838,7 +1838,7 @@ Final file size is 187200 bytes, 78.60% of original.
\noindent The \texttt{-squeeze-log-to <filename>} option writes the log to the given file instead of to standard output. Log contents is appended to the end of the log file, preserving existing contents.
There are two options which turn off parts of the squeezer. They are \texttt{-squeeze-no-recompress} for avoiding the reprocessing of malformed compressed sections, and \texttt{-squeeze-no-pagedata} for avoiding the reprocessing of malformed page data.
There are two options which turn off parts of the squeezer. They are \texttt{-squeeze-no-recompress} for avoiding the reprocessing of compressed sections (especially useful if they are malformed), and \texttt{-squeeze-no-pagedata} for avoiding the reprocessing of page data (ditto). These two options also make the process much faster at the cost of a little less compression. Experiment.
\begin{cpdflib}
\clearpage

View File

@ -36,7 +36,6 @@ let decompress_pdf pdf =
(Pdf.iter_stream (Pdfcodec.decode_pdfstream_until_unknown pdf) pdf);
pdf
(* Equality on PDF objects *)
let pdfobjeq pdf x y =
let x = Pdf.lookup_obj pdf x
@ -235,10 +234,16 @@ let squeeze ?logto ?(pagedata=true) ?(recompress=true) pdf =
end;
if recompress then
begin
ignore (decompress_pdf pdf);
log (Printf.sprintf "Recompressing document\n");
let n = !Pdfcodec.flate_level in
Pdfcodec.flate_level := 9;
ignore (recompress_pdf pdf)
ignore (recompress_pdf pdf);
Pdfcodec.flate_level := n
end
else
(* Re-compress processed pagedata, even if recompress not set *)
if pagedata then ignore (recompress_pdf pdf)
with
e ->
raise