From 415c172354bff731462a2135536a913ca5f688b4 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 22 Jan 2024 15:53:41 +0000 Subject: [PATCH] Adds -merge-no-struct-trees --- Changes | 2 ++ cpdfcommand.ml | 11 ++++++++++- cpdfmanual.tex | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index c28660b..4ceabea 100644 --- a/Changes +++ b/Changes @@ -32,6 +32,7 @@ o Report number of annotations in -page-info o Specify image based only on file extension o -squeeze updates old compression methods o Show page size summary in -info +o Add -no-merge-struct-trees to prevent merging of structure trees Fixes: @@ -40,6 +41,7 @@ o Fixed -set-annotations with page links o Allow Exif JPEGs as well as JFIF ones in -jpeg and -draw-jpeg o Only compress a stream if it actually makes it smaller + 2.6.1 (September 2023) o Fixed regression in UTF8 text with -add-text diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 61c6b3a..77e11ce 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -459,6 +459,7 @@ type args = mutable boxes : bool; mutable encrypt_metadata : bool; mutable retain_numbering : bool; + mutable merge_struct_trees : bool; mutable remove_duplicate_fonts : bool; mutable remove_duplicate_streams : bool; mutable encoding : Cpdfmetadata.encoding; @@ -593,6 +594,7 @@ let args = boxes = false; encrypt_metadata = true; retain_numbering = false; + merge_struct_trees = true; remove_duplicate_fonts = false; remove_duplicate_streams = false; encoding = Cpdfmetadata.UTF8; @@ -732,6 +734,7 @@ let reset_arguments () = args.boxes <- false; args.encrypt_metadata <- true; args.retain_numbering <- false; + args.merge_struct_trees <- true; args.remove_duplicate_fonts <- false; args.remove_duplicate_streams <- false; args.encoding <- Cpdfmetadata.UTF8; @@ -2013,6 +2016,9 @@ let setextractstreamdecomp i = let setprintobj i = args.op <- Some (PrintObj i) +let setnomergestructtrees () = + args.merge_struct_trees <- false + (* Parse a control file, make an argv, and then make Arg parse it. *) let rec make_control_argv_and_parse filename = control_args := !control_args @ parse_control_file filename @@ -2129,6 +2135,9 @@ and specs = ("-merge-add-bookmarks-use-titles", Arg.Unit setmergeaddbookmarksusetitles, " Use title of document rather than filename"); + ("-no-merge-struct-trees", + Arg.Unit setnomergestructtrees, + " Do not merge structure trees"); ("-remove-duplicate-fonts", Arg.Unit set_remove_duplicate_fonts, " Remove duplicate fonts when merging"); @@ -3652,7 +3661,7 @@ let go () = in let outpdf = Pdfmerge.merge_pdfs - args.retain_numbering args.remove_duplicate_fonts names pdfs rangenums + args.retain_numbering args.remove_duplicate_fonts ~struct_hierarchy:args.merge_struct_trees names pdfs rangenums in if args.remove_duplicate_streams then Pdfmerge.remove_duplicate_fonts outpdf; (* JBIG2 Globals *) write_pdf false outpdf diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 899df54..4a32394 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -15,6 +15,7 @@ %Document -png -jpeg -jbig2 by extension %Document -extract-stream - check enc %Document -obj - check enc +%Document -merge-no-struct-trees in merge and collate \documentclass{book} % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.