From 89c634ab8c51781d14d3b5eee29f770632bb6030 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 27 Mar 2018 18:02:20 +0100 Subject: [PATCH] Fixed extract images to add page prefix --- cpdfcommand.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 80816aa..d6749fe 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2587,8 +2587,8 @@ let extract_images pdf range stem = (function (i, pdf_pages) -> if mem i range then Some pdf_pages else None) (combine (indx pdf_pages) pdf_pages) in - iter - (function page -> + iter2 + (fun page pnum -> let xobjects = match Pdf.lookup_direct pdf "/XObject" page.Pdfpage.resources with | Some (Pdf.Dictionary elts) -> map snd elts @@ -2600,11 +2600,13 @@ let extract_images pdf range stem = if images <> [] then (let names = map - (function n -> let r = Cpdf.name_of_spec [] (*FIXME *) pdf 0 stem n "" 0 0 in (*i flprint r; flprint "\n"; i*) r) - (ilist 1 (length images)) + (function n -> + let r = Cpdf.name_of_spec [] pdf 0 ("p" ^ string_of_int pnum ^ "_" ^ stem) n "" 0 0 in r) + (indx images) in iter2 (write_image pdf page.Pdfpage.resources) names images)) pages + (indx pages) let getencryption pdf = match Pdfread.what_encryption pdf with