more
This commit is contained in:
parent
6616516f77
commit
a9bfd16142
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
# Build the cpdf command line tools and top level
|
||||
MODS = cpdfyojson cpdfxmlm \
|
||||
cpdfunicodedata cpdferror cpdfjson cpdfstrftime cpdfcoord cpdfattach \
|
||||
cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord cpdfattach \
|
||||
cpdfpagespec cpdfposition cpdfpresent cpdfmetadata cpdf cpdffont cpdftype \
|
||||
cpdftexttopdf cpdftoc cpdfpad cpdfocg cpdfsqueeze cpdfspot cpdfpagelabels cpdfcreate cpdfcommand
|
||||
|
||||
|
|
28
cpdf.ml
28
cpdf.ml
|
@ -8,34 +8,6 @@ type color =
|
|||
| RGB of float * float * float
|
||||
| CYMK of float * float * float * float
|
||||
|
||||
let debug = ref false
|
||||
|
||||
(* Get the number of pages in file. Doesn't need decryption. *)
|
||||
let endpage_io ?revision i user_pw owner_pw =
|
||||
let pdf = Pdfread.pdf_of_input_lazy ?revision user_pw owner_pw i in
|
||||
Pdfpage.endpage pdf
|
||||
|
||||
let print_pdf_objs pdf =
|
||||
Printf.printf "Trailerdict: %s\n" (Pdfwrite.string_of_pdf pdf.Pdf.trailerdict);
|
||||
Printf.printf "Root: %i\n" pdf.Pdf.root;
|
||||
begin match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
||||
| Some catalog ->
|
||||
Printf.printf "Catalog: %s\n" (Pdfwrite.string_of_pdf catalog);
|
||||
begin match Pdf.lookup_direct pdf "/Pages" catalog with
|
||||
| Some pages ->
|
||||
Printf.printf "Pages: %s\n" (Pdfwrite.string_of_pdf pages)
|
||||
| None ->
|
||||
flprint "no catalog\n"
|
||||
end
|
||||
| None ->
|
||||
flprint "No catalog!\n"
|
||||
end;
|
||||
Pdf.objiter
|
||||
(fun n obj ->
|
||||
Printf.printf "%i 0 obj:\n\n" n;
|
||||
Printf.printf "%s\n" (Pdfwrite.string_of_pdf obj))
|
||||
pdf
|
||||
|
||||
(* Return page label at pdf page num, or page number in arabic if no label *)
|
||||
let pagelabel pdf num =
|
||||
Pdfpagelabels.pagelabeltext_of_pagenumber
|
||||
|
|
20
cpdf.mli
20
cpdf.mli
|
@ -1,23 +1,13 @@
|
|||
(** Coherent PDF Tools Core Routines *)
|
||||
open Pdfutil
|
||||
|
||||
|
||||
type color =
|
||||
Grey of float
|
||||
| RGB of float * float * float
|
||||
| CYMK of float * float * float * float
|
||||
|
||||
(** {2 Debug} *)
|
||||
|
||||
(** Debug: Print out a PDF in readable form to the terminal *)
|
||||
val print_pdf_objs : Pdf.t -> unit
|
||||
|
||||
(** {2 Working with pages} *)
|
||||
|
||||
(** Like [Pdfpage.endpage], but from an input and possible password - does the
|
||||
minimal work to find the number of pages. *)
|
||||
val endpage_io : ?revision:int -> Pdfio.input -> string option -> string option -> int
|
||||
|
||||
(** Given a function from page number and page to page, a document, and a list
|
||||
of page numbers to apply it to, apply the function to all those pages. *)
|
||||
val process_pages : (int -> Pdfpage.t -> Pdfpage.t * int * Pdftransform.transform_matrix) ->
|
||||
|
@ -46,8 +36,6 @@ val add_bookmarks : json:bool -> bool -> Pdfio.input -> Pdf.t -> Pdf.t
|
|||
output in the format specified in cpdfmanual.pdf *)
|
||||
val list_bookmarks : json:bool -> Cpdfmetadata.encoding -> int list -> Pdf.t -> Pdfio.output -> unit
|
||||
|
||||
|
||||
|
||||
(** {2 Stamping} *)
|
||||
|
||||
(** [combine_pages fast under over scaletofit swap equalize] combines the page
|
||||
|
@ -207,7 +195,6 @@ val trim_marks : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
|||
|
||||
val show_boxes : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
||||
|
||||
|
||||
(** {2 Annotations} *)
|
||||
|
||||
(** List the annotations to standard output in a given encoding. See cpdfmanual.pdf for the format details. *)
|
||||
|
@ -252,15 +239,12 @@ val blackfills : color -> int list -> Pdf.t -> Pdf.t
|
|||
(** Remove images from a PDF, optionally adding crossed boxes. *)
|
||||
val draft : string option -> bool -> int list -> Pdf.t -> Pdf.t
|
||||
|
||||
|
||||
val remove_all_text : int list -> Pdf.t -> Pdf.t
|
||||
|
||||
(**/**)
|
||||
|
||||
val process_xobjects : Pdf.t -> Pdfpage.t -> (Pdf.t -> Pdf.pdfobject -> Pdf.pdfobject list -> Pdf.pdfobject list) -> unit
|
||||
|
||||
val debug : bool ref
|
||||
|
||||
val extract_text : float option -> Pdf.t -> int list -> string
|
||||
|
||||
val append_page_content : string -> bool -> bool -> int list -> Pdf.t -> Pdf.t
|
||||
|
@ -279,8 +263,6 @@ val image_resolution : Pdf.t -> int list -> float -> (int * string * int * int *
|
|||
|
||||
val copy_box : string -> string -> bool -> Pdf.t -> int list -> Pdf.t
|
||||
|
||||
|
||||
|
||||
val add_bookmark_title : string -> bool -> Pdf.t -> Pdf.t
|
||||
|
||||
val remove_unused_resources : Pdf.t -> Pdf.t
|
||||
|
@ -296,5 +278,3 @@ val name_of_spec : Cpdfmetadata.encoding ->
|
|||
val extract_images : string ->
|
||||
string ->
|
||||
Cpdfmetadata.encoding -> bool -> bool -> Pdf.t -> int list -> string -> unit
|
||||
|
||||
|
||||
|
|
|
@ -1298,7 +1298,6 @@ let setdebug () =
|
|||
set Pdfwrite.write_debug;
|
||||
set Pdfcrypt.crypt_debug;
|
||||
set Pdfops.debug;
|
||||
set Cpdf.debug;
|
||||
args.debug <- true
|
||||
|
||||
let setdebugcrypt () =
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
open Pdfutil
|
||||
|
||||
let blank_document width height pages =
|
||||
let pdf_pages =
|
||||
map (fun () -> Pdfpage.blankpage (Pdfpaper.make Pdfunits.PdfPoint width height)) (many () pages)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
open Pdfutil
|
||||
|
||||
let print_pdf_objs pdf =
|
||||
Printf.printf "Trailerdict: %s\n" (Pdfwrite.string_of_pdf pdf.Pdf.trailerdict);
|
||||
Printf.printf "Root: %i\n" pdf.Pdf.root;
|
||||
begin match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
||||
| Some catalog ->
|
||||
Printf.printf "Catalog: %s\n" (Pdfwrite.string_of_pdf catalog);
|
||||
begin match Pdf.lookup_direct pdf "/Pages" catalog with
|
||||
| Some pages ->
|
||||
Printf.printf "Pages: %s\n" (Pdfwrite.string_of_pdf pages)
|
||||
| None ->
|
||||
flprint "no catalog\n"
|
||||
end
|
||||
| None ->
|
||||
flprint "No catalog!\n"
|
||||
end;
|
||||
Pdf.objiter
|
||||
(fun n obj ->
|
||||
Printf.printf "%i 0 obj:\n\n" n;
|
||||
Printf.printf "%s\n" (Pdfwrite.string_of_pdf obj))
|
||||
pdf
|
|
@ -0,0 +1 @@
|
|||
val print_pdf_objs : Pdf.t -> unit
|
Loading…
Reference in New Issue