Fix double-artifacts bug

This commit is contained in:
John Whitington 2024-09-17 14:32:22 +01:00
parent ee917c8c7d
commit 43fba37747
1 changed files with 10 additions and 2 deletions

View File

@ -427,8 +427,8 @@ let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num
| EndTag -> [Pdfops.Op_EMC] | EndTag -> [Pdfops.Op_EMC]
| STag s -> structdata =| StDataBeginTree s; [] | STag s -> structdata =| StDataBeginTree s; []
| EndSTag -> structdata =| StDataEndTree; [] | EndSTag -> structdata =| StDataEndTree; []
| BeginArtifact -> [Pdfops.Op_BMC "/Artifact"] | BeginArtifact -> [Pdfops.Op_BMC "/BeginArtifact"]
| EndArtifact -> [Pdfops.Op_EMC] | EndArtifact -> [Pdfops.Op_BMC "/EndArtifact"]
and ops_of_drawops struct_tree dryrun pdf endpage filename bates batespad num page drawops = and ops_of_drawops struct_tree dryrun pdf endpage filename bates batespad num page drawops =
flatten (map (ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num page) drawops) flatten (map (ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num page) drawops)
@ -500,6 +500,14 @@ let add_artifacts ops =
| [] -> | [] ->
(* The end. Must end artifact if in artifact. *) (* The end. Must end artifact if in artifact. *)
if !artifact then rev (Pdfops.Op_EMC::a) else rev a if !artifact then rev (Pdfops.Op_EMC::a) else rev a
| Pdfops.Op_BMC "/BeginArtifact"::t ->
(* Convert back-channel artifact beginning. *)
set artifact;
loop (Pdfops.Op_BMC "/Artifact"::a) t
| Pdfops.Op_BMC "/EndArtifact"::t ->
(* Convert back-channel artifact ending. *)
clear artifact;
loop (Pdfops.Op_EMC::a) t
| Pdfops.Op_BDC _ as h::t -> | Pdfops.Op_BDC _ as h::t ->
(* Entering content. If in artifact, must end artifact. *) (* Entering content. If in artifact, must end artifact. *)
let a' = if !artifact then h::Pdfops.Op_EMC::a else h::a in let a' = if !artifact then h::Pdfops.Op_EMC::a else h::a in