diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 5face0b..508917f 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3754,7 +3754,9 @@ let rasterize antialias downsample device res annots quality pdf range = [Pdftransform.Translate (tx, ty); Pdftransform.Scale ((0., 0.), float_of_int w *. 72. /. res, float_of_int h *. 72. /. res); Pdftransform.Rotate ((0., 0.), rotation)]); - Pdfops.Op_Do "/I0"] + Pdfops.Op_BMC "/Artifact"; + Pdfops.Op_Do "/I0"; + Pdfops.Op_EMC] in {page with Pdfpage.content = [Pdfops.stream_of_ops ops]; Pdfpage.resources = Pdf.Dictionary [("/XObject", Pdf.Dictionary [("/I0", Pdf.Indirect imageobj)])]}) @@ -4533,15 +4535,15 @@ let go () = | Some RemoveBookmarks -> write_pdf false (Pdfmarks.remove_bookmarks (get_single_pdf args.op false)) | Some TwoUp -> - write_pdf false (Cpdfimpose.twoup args.fast (get_single_pdf args.op false)) + write_pdf false (Cpdfimpose.twoup ~process_struct_tree:args.process_struct_trees args.fast (get_single_pdf args.op false)) | Some TwoUpStack -> - write_pdf false (Cpdfimpose.twoup_stack args.fast (get_single_pdf args.op false)) + write_pdf false (Cpdfimpose.twoup_stack ~process_struct_tree:args.process_struct_trees args.fast (get_single_pdf args.op false)) | Some Impose fit -> let pdf = get_single_pdf args.op false in let x, y = Cpdfcoord.parse_coordinate pdf args.coord in if not fit && (x < 0.0 || y < 0.0) then error "Negative imposition parameters not allowed." else write_pdf false - (Cpdfimpose.impose ~x ~y ~fit ~columns:args.impose_columns ~rtl:args.impose_rtl ~btt:args.impose_btt ~center:args.impose_center + (Cpdfimpose.impose ~process_struct_tree:args.process_struct_trees ~x ~y ~fit ~columns:args.impose_columns ~rtl:args.impose_rtl ~btt:args.impose_btt ~center:args.impose_center ~margin:args.impose_margin ~spacing:args.impose_spacing ~linewidth:args.impose_linewidth ~fast:args.fast pdf) | Some (StampOn over) -> let overpdf = diff --git a/cpdfimpose.ml b/cpdfimpose.ml index 46211df..fcc7a15 100644 --- a/cpdfimpose.ml +++ b/cpdfimpose.ml @@ -191,7 +191,8 @@ let add_border linewidth ~fast pdf = fast (w -. linewidth, h -. linewidth) (RGB (0., 0., 0.)) true linewidth 1. (Cpdfposition.BottomLeft (linewidth /. 2., linewidth /. 2.)) false false (ilist 1 (Pdfpage.endpage pdf)) pdf -let impose ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fast pdf = +let impose ~process_struct_tree ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fast pdf = + let pdf = if process_struct_tree then Cpdfpage.mark_all_as_artifact pdf else pdf in let endpage = Pdfpage.endpage pdf in let pagenums = ilist 1 endpage in let pdf = Cpdfpage.copy_box "/CropBox" "/MediaBox" true pdf pagenums in @@ -244,17 +245,17 @@ let impose ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fa if fit then pdf else Cpdfpage.shift_pdf ~fast (many (margin, margin) (length pages)) pdf (ilist 1 (Pdfpage.endpage pdf)) (* Legacy -twoup-stack. Impose 2x1 on a page twice the size then rotate. *) -let twoup_stack fast pdf = +let twoup_stack ~process_struct_tree fast pdf = let pdf = impose - ~x:2. ~y:1. ~fit:false ~columns:false ~rtl:false ~btt:false ~center:false + ~process_struct_tree ~x:2. ~y:1. ~fit:false ~columns:false ~rtl:false ~btt:false ~center:false ~margin:0. ~spacing:0. ~linewidth:0. ~fast pdf in let all = ilist 1 (Pdfpage.endpage pdf) in Cpdfpage.upright ~fast all (Cpdfpage.rotate_pdf ~-90 pdf all) (* Legacy -two-up. Rotate the pages and shrink them so as to fit 2x1 on a page the same size. *) -let twoup fast pdf = +let twoup ~process_struct_tree fast pdf = let firstpage = hd (Pdfpage.pages_of_pagetree pdf) in let width, height = match Pdf.parse_rectangle pdf firstpage.Pdfpage.mediabox with @@ -271,7 +272,7 @@ let twoup fast pdf = let pdf = Cpdfpage.scale_pdf ~fast (many (sc, sc) endpage) pdf all in let pdf = impose - ~x:2. ~y:1. ~fit:false ~columns:false ~rtl:false ~btt:false ~center:true + ~process_struct_tree ~x:2. ~y:1. ~fit:false ~columns:false ~rtl:false ~btt:false ~center:true ~margin:0. ~spacing:0. ~linewidth:0. ~fast pdf in let endpage = Pdfpage.endpage pdf in diff --git a/cpdfimpose.mli b/cpdfimpose.mli index 605fcb1..011612b 100644 --- a/cpdfimpose.mli +++ b/cpdfimpose.mli @@ -1,13 +1,13 @@ (** Imposition *) (** Imposition. See cpdfmanual.pdf for details. *) -val impose : x:float -> y:float -> fit:bool -> columns:bool -> rtl:bool -> btt:bool -> center:bool -> margin:float -> spacing:float -> linewidth:float -> fast:bool -> Pdf.t -> Pdf.t +val impose : process_struct_tree:bool -> x:float -> y:float -> fit:bool -> columns:bool -> rtl:bool -> btt:bool -> center:bool -> margin:float -> spacing:float -> linewidth:float -> fast:bool -> Pdf.t -> Pdf.t (** The legacy twoup_stack operation puts two logical pages on each physical page, rotating them 90 degrees to do so. The new mediabox is thus larger. Bool true (fast) if assume well-formed ISO content streams. *) -val twoup_stack : bool -> Pdf.t -> Pdf.t +val twoup_stack : process_struct_tree:bool -> bool -> Pdf.t -> Pdf.t (** The legacy twoup operation does the same, but scales the new sides down so that the media box is unchanged. Bool true (fast) if assume well-formed ISO content streams. *) -val twoup : bool -> Pdf.t -> Pdf.t +val twoup : process_struct_tree:bool -> bool -> Pdf.t -> Pdf.t