Add %Objnum to -extract-images to allow cross-referencing

This commit is contained in:
John Whitington
2025-02-17 13:22:21 +08:00
parent 7353d3811b
commit 1b9555bd23
3 changed files with 11 additions and 5 deletions

View File

@ -9,6 +9,7 @@ o -obj JSON output
can follow a chain from each found dictionary entry
* More of the PDF/UA Matterhorn verification suite implemented
* Font lister now returns the font itself
o Allow %objnum in output name for -extract-images
Fixes:

View File

@ -128,11 +128,15 @@ let write_image ~raw ?path_to_p2p ?path_to_im pdf resources name image =
let written = ref []
let extract_images_inner ~raw ?path_to_p2p ?path_to_im encoding serial pdf resources stem pnum images =
let names = map
(fun _ ->
Cpdfbookmarks.name_of_spec
encoding [] pdf 0 (stem ^ "-p" ^ string_of_int pnum)
(let r = !serial in serial := !serial + 1; r) "" 0 0) (indx images)
let names =
map
(fun image ->
(* Abuse @S *)
let stem = string_replace_all "%objnum" "@S" stem in
Cpdfbookmarks.name_of_spec
encoding [] pdf 0 (stem ^ "-p" ^ string_of_int pnum)
(let r = !serial in serial := !serial + 1; r) "" (match image with Pdf.Indirect i -> i | _ -> 0) 0)
images
in
iter2 (write_image ~raw ?path_to_p2p ?path_to_im pdf resources) names images

View File

@ -1,3 +1,4 @@
%Document %objnum in -extract-images
%\DocumentMetadata{lang=en, pdfversion=2.0, pdfstandard=ua-2, pdfstandard=a-4f, testphase={phase-III, title, table, math, firstaid}}
\documentclass{book}
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,