diff --git a/blank20.pdf b/blank20.pdf index 7a898f8..23d177b 100644 Binary files a/blank20.pdf and b/blank20.pdf differ diff --git a/cpdf.ml b/cpdf.ml index 099b9c9..ce48d7c 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -966,10 +966,18 @@ let bookmark_of_data pdf i s i' isopen optionaldest = let pdfobj = Pdfread.parse_single_object s in - Printf.printf "Parsed %s\n" (Pdfwrite.string_of_pdf pdfobj); + (*Printf.printf "Parsed %s\n" (Pdfwrite.string_of_pdf pdfobj);*) begin match pdfobj with Pdf.Array (Pdf.Integer x::more) -> - Pdfdest.read_destination (Pdf.empty ()) (Pdf.Array (Pdf.Indirect 0::more)) + let pageobjnum = Pdfpage.page_object_number pdf i' in + begin match pageobjnum with + None -> + raise (Pdf.PDFError "bookmark_of_data: page obj num not found") + | Some p -> + Pdfdest.read_destination + (Pdf.empty ()) + (Pdf.Array (Pdf.Indirect p::more)) + end | _ -> raise (Pdf.PDFError "bookmark_of_data: dest") end