Fixed outlines in -stamp-on, -stamp-under

This commit is contained in:
John Whitington 2016-07-24 14:53:24 +01:00
parent e7e3b5bb0b
commit bc20b01061
2 changed files with 14 additions and 5 deletions

15
cpdf.ml
View File

@ -2268,11 +2268,19 @@ let stamp relative_to_cropbox position topline midline fast scale_to_fit isover
pageseqs
under_pages
in
let changed = Pdfpage.change_pages true merged new_pages in
let new_refnumbers = Pdf.page_reference_numbers changed in
let changed = Pdfpage.change_pages true merged (new_pages @ [last new_pages]) in
(* we use new_pages @ new_pages here to preserve the number of pages
* so that Pdfpage.change_pages can do its renumbering properly.
* Otherwise things like outlines are lost. TODO: Fix
* Pdfpage.change_pages properly. For now, we just use
* Pdfpage.pdf_of_pages afterward to chop it. *)
let cut =
Pdfpage.pdf_of_pages ~retain_numbering:true changed (ilist 1 (length new_pages))
in
let new_refnumbers = Pdf.page_reference_numbers cut in
let changetable = hashtable_of_dictionary (List.combine marks_refnumbers new_refnumbers) in
let new_marks = map (change_bookmark changetable) marks in
Pdfmarks.add_bookmarks new_marks changed
Pdfmarks.add_bookmarks new_marks cut
(* Combine pages from two PDFs. For now, assume equal length. *)
@ -2325,6 +2333,7 @@ let combine_pages (fast : bool) under over scaletofit swap equalize =
* Otherwise things like outlines are lost. TODO: Fix
* Pdfpage.change_pages properly. For now, we just use
* Pdfpage.pdf_of_pages afterward to chop it. *)
(* See also combine_pages below *)
let changed = Pdfpage.change_pages true merged (new_pages @ new_pages) in
let cut =
Pdfpage.pdf_of_pages ~retain_numbering:true changed (ilist 1 (length new_pages))

View File

@ -1,10 +1,10 @@
(* Added -relative-to-cropbox for stamps *)
(* cpdf command line tools *)
let demo = false
let noncomp = true
let noncomp = false
let major_version = 2
let minor_version = 2
let version_date = "(build of 3rd April 2016)"
let version_date = "(build of 24th July 2016)"
open Pdfutil
open Pdfio