From c8c8ddcae997bc3c391859810ffd7ca0858c9e70 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 28 Nov 2024 16:37:37 +0000 Subject: [PATCH] Deep copy --- cpdfcommand.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index ab478f8..017c509 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3758,7 +3758,8 @@ let write_images device res quality boxname annots antialias downsample spec pdf end; let tmppdf = Filename.temp_file "cpdf" ".pdf" in tempfiles := tmppdf::!tempfiles; - Pdfwrite.pdf_to_file pdf tmppdf; + Pdfwrite.pdf_to_file (Pdf.deep_copy pdf) tmppdf; + let endpage = Pdfpage.endpage pdf in iter2 (fun page pnum -> if not (mem pnum range) then () else @@ -3783,7 +3784,7 @@ let write_images device res quality boxname annots antialias downsample spec pdf | _ -> Pdfe.log "Rasterization failed\n"; exit 2 end) (Pdfpage.pages_of_pagetree pdf) - (ilist 1 (Pdfpage.endpage pdf)); + (ilist 1 endpage); Sys.remove tmppdf (* Main function *)