Proper artifacting for drawing

This commit is contained in:
John Whitington 2025-03-12 16:41:19 +00:00
parent 8fa6c6ae5c
commit 084c7f485f
2 changed files with 10 additions and 4 deletions

View File

@ -622,7 +622,7 @@ let draw_single ~struct_tree ~fast ~underneath ~filename ~bates ~batespad range
map3
(fun n p ops ->
if not (mem n range) then p else
let ops = if struct_tree && !do_add_artifacts then Cpdftype.add_artifacts ops else fixup_manual_artifacts ops in
let ops = if !do_add_artifacts then Cpdftype.add_artifacts ops else fixup_manual_artifacts ops in
let page = {p with Pdfpage.resources = update_resources pdf p.Pdfpage.resources} in
(if underneath then Pdfpage.prepend_operators else Pdfpage.postpend_operators) pdf ops ~fast page)
(ilist 1 endpage)
@ -778,8 +778,14 @@ let write_structure_tree pdf st =
Pdf.replace_chain pdf ["/Root"; "/StructTreeRoot"] (Pdf.Indirect struct_tree_root)
let draw ~struct_tree ~fast ~underneath ~filename ~bates ~batespad range pdf drawops =
(*Printf.printf "%s\n" (string_of_drawops drawops);*)
if not struct_tree then clear do_add_artifacts;
let is_fresh =
match Pdf.lookup_chain pdf (Pdf.lookup_obj pdf pdf.Pdf.root) ["/StructTreeRoot"] with
| Some (Pdf.Dictionary [("/Type", Pdf.Name "/StructTreeRoot")]) -> true
| _ -> false
in
let auto_auto_artifact = not is_fresh && struct_tree in
let struct_tree = is_fresh && struct_tree in
if not struct_tree && not auto_auto_artifact then clear do_add_artifacts;
resstack := [empty_res ()];
Hashtbl.clear !fontpacks;
(res ()).time <- Cpdfstrftime.current_time ();

View File

@ -1,4 +1,4 @@
%Document -mark-as-artifact
%Document that -draw-struct-tree when drawing on existing file will artifact the drawing
%\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,