Smaller splits for -split-bookmarks with object streams

This commit is contained in:
John Whitington 2014-09-25 15:12:30 +01:00
parent 5fb0a3b7cc
commit 838fc69c18
3 changed files with 10 additions and 14 deletions

15
cpdf.ml
View File

@ -1290,20 +1290,15 @@ let bookmark_pages level pdf =
(function l when l.Pdfmarks.level = level -> Some (Pdfpage.pagenumber_of_target pdf l.Pdfmarks.target) | _ -> None) (function l when l.Pdfmarks.level = level -> Some (Pdfpage.pagenumber_of_target pdf l.Pdfmarks.target) | _ -> None)
(Pdfmarks.read_bookmarks pdf)) (Pdfmarks.read_bookmarks pdf))
let split_at_bookmarks original_filename linearize nobble level spec pdf = let split_at_bookmarks original_filename linearize ~preserve_objstm ~create_objstm nobble level spec pdf =
(*flprint "split_at_bookmarks\n";*) let pdf_pages = Pdfpage.pages_of_pagetree pdf in
let pdf_pages = Pdfpage.pages_of_pagetree pdf let points = bookmark_pages level pdf in
in let points = bookmark_pages level pdf in
let points = let points =
lose (fun x -> x <= 0 || x > Pdfpage.endpage pdf) (map pred points) (* FIXME: What actually causes these problems? *) lose (fun x -> x <= 0 || x > Pdfpage.endpage pdf) (map pred points)
in in
(*flprint "Points: ";
iter (Printf.printf "%i ,") points;
flprint "\n";*)
let pts = splitat points (indx pdf_pages) in let pts = splitat points (indx pdf_pages) in
(*flprint "Calling fast_write_split_pdfs\n";*)
fast_write_split_pdfs None false level fast_write_split_pdfs None false level
original_filename linearize false false nobble spec pdf pts pdf_pages original_filename linearize preserve_objstm create_objstm nobble spec pdf pts pdf_pages
(* Called from cpdflib.ml - different from above *) (* Called from cpdflib.ml - different from above *)
let split_on_bookmarks pdf level = let split_on_bookmarks pdf level =

View File

@ -189,7 +189,7 @@ val stamp : bool -> bool -> bool -> int list -> Pdf.t -> Pdf.t -> Pdf.t
the fiven level, writing to files with names given by [spec] (see the fiven level, writing to files with names given by [spec] (see
cpdfmanual.pdf). [nobble] is undocumented and should be false. If [linearize] cpdfmanual.pdf). [nobble] is undocumented and should be false. If [linearize]
is true, the files will be linearized. *) is true, the files will be linearized. *)
val split_at_bookmarks : string -> bool -> (Pdf.t -> Pdf.t) -> int -> string -> Pdf.t -> unit val split_at_bookmarks : string -> bool -> preserve_objstm:bool -> create_objstm:bool -> (Pdf.t -> Pdf.t) -> int -> string -> Pdf.t -> unit
(** Split a PDF on bookmarks of a given level or below. Level 0 is top level. *) (** Split a PDF on bookmarks of a given level or below. Level 0 is top level. *)
val split_on_bookmarks : Pdf.t -> int -> Pdf.t list val split_on_bookmarks : Pdf.t -> int -> Pdf.t list

View File

@ -3324,7 +3324,8 @@ let go () =
| [(InFile f, _, _, _, _)] -> f | [(InFile f, _, _, _, _)] -> f
| _ -> "" | _ -> ""
in in
Cpdf.split_at_bookmarks filename args.linearize nobble level output_spec pdf Cpdf.split_at_bookmarks filename args.linearize args.preserve_objstm
(* Yes *)args.preserve_objstm nobble level output_spec pdf
| Stdout -> error "Can't split to standard output" | Stdout -> error "Can't split to standard output"
| NoOutputSpecified -> error "Split: No output format specified" | NoOutputSpecified -> error "Split: No output format specified"
end end