2013-08-20 16:32:57 +02:00
|
|
|
(** Coherent PDF Tools Core Routines *)
|
|
|
|
open Pdfutil
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** {2 Working with pages} *)
|
|
|
|
|
2021-10-26 17:18:09 +02:00
|
|
|
val copy_cropbox_to_mediabox : Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** {2 Stamping} *)
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-28 17:54:23 +02:00
|
|
|
(** [combine_pages fast under over scaletofit swap equalize] combines the page
|
|
|
|
content of two PDFs, page-by-page. If [equalize] is true the output will have
|
|
|
|
the same number of pages as the shorter file. If [scaletofit] is true, the
|
|
|
|
[over] file will be scaled to fit. If [swap] is true, [over] and [under] are
|
|
|
|
swapped. If [fast] is true, the PDFs are assumed to be well-formed and no
|
|
|
|
fixes are done. *)
|
2013-08-27 18:35:16 +02:00
|
|
|
val combine_pages : bool -> Pdf.t -> Pdf.t -> bool -> bool -> bool -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2017-01-10 20:52:57 +01:00
|
|
|
(** [stamp relative_to_cropbox position topline midline fast scale_to_fit isover range over pdf] stamps the first page of
|
2013-08-28 17:54:23 +02:00
|
|
|
[over] over each page of the PDF. The arguments have the same meaning as in
|
|
|
|
[combine_pages]. *)
|
2021-08-12 21:38:55 +02:00
|
|
|
val stamp : bool -> Cpdfposition.position -> bool -> bool -> bool -> bool -> bool -> int list -> Pdf.t -> Pdf.t -> Pdf.t
|
2013-08-27 18:35:16 +02:00
|
|
|
|
|
|
|
(** {2 Page geometry} *)
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-29 12:54:56 +02:00
|
|
|
(** True if a given page in a PDF has a given box *)
|
2013-08-27 18:35:16 +02:00
|
|
|
val hasbox : Pdf.t -> int -> string -> bool
|
|
|
|
|
2016-07-21 18:02:11 +02:00
|
|
|
(** [crop_pdf xywhlist pdf range] sets the cropbox on the given pages. *)
|
2019-06-26 15:43:24 +02:00
|
|
|
val crop_pdf : ?box:string -> (float * float * float * float) list -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2017-05-19 20:10:49 +02:00
|
|
|
val hard_box : Pdf.t -> int list -> string -> bool -> bool -> Pdf.t
|
|
|
|
|
2016-07-21 18:02:11 +02:00
|
|
|
(** [set_mediabox xywhlist pdf range] sets the media box on the given pages. *)
|
|
|
|
val set_mediabox : (float * float * float * float) list -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2019-08-08 17:57:25 +02:00
|
|
|
(** [setBox boxname x y w h pdf range] sets the given box on the given pages. *)
|
|
|
|
val setBox : string -> float -> float -> float -> float -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Remove any cropping from the given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val remove_cropping_pdf : Pdf.t -> int list -> Pdf.t
|
2013-08-29 12:54:56 +02:00
|
|
|
|
|
|
|
(** Remove any trim box from the given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val remove_trim_pdf : Pdf.t -> int list -> Pdf.t
|
2013-08-29 12:54:56 +02:00
|
|
|
|
|
|
|
(** Remove any bleed box from the given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val remove_bleed_pdf : Pdf.t -> int list -> Pdf.t
|
2013-08-29 12:54:56 +02:00
|
|
|
|
|
|
|
(** Remove any art box from the given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val remove_art_pdf : Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Change rotation to a given value 0, 90, 180, 270 on given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val rotate_pdf : int -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Rotate clockwise by 0, 90, 180, 270 on given pages. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val rotate_pdf_by : int -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-29 12:54:56 +02:00
|
|
|
(** Rotate the contents by the given angle on the given pages. If [fast] is true, assume PDF is well-formed. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val rotate_contents : ?fast:bool -> float -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Modify the rotation of the page and its contents to leave the rotation at 0 with the page effectively unaltered. *)
|
|
|
|
val upright : ?fast:bool -> int list -> Pdf.t -> Pdf.t
|
|
|
|
|
|
|
|
(** Flip the given pages vertically *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val vflip_pdf : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Flip the given pages horizontally *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val hflip_pdf : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2016-07-21 18:02:11 +02:00
|
|
|
(** Shift a PDF in x and y (in pts) in the given pages. List of (x, y) pairs is
|
|
|
|
for all pages in pdf. *)
|
|
|
|
val shift_pdf : ?fast:bool -> (float * float) list -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2016-07-21 18:02:11 +02:00
|
|
|
(** Scale a PDF in sx, sy in the given pages. List of (sx, sy) pairs is
|
|
|
|
for all pages in pdf. *)
|
|
|
|
val scale_pdf : ?fast:bool -> (float * float) list -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2019-03-19 15:03:28 +01:00
|
|
|
(** [scale_to_fit_pdf fast position input_scale x y op pdf range] scales a page to fit the
|
2013-08-29 12:54:56 +02:00
|
|
|
page size given by (x, y) and by the [input_scale] (e.g 1.0 = scale to fit, 0.9
|
|
|
|
= scale to fit leaving a border etc.). [op] is unused. *)
|
2021-08-12 21:38:55 +02:00
|
|
|
val scale_to_fit_pdf : ?fast:bool -> Cpdfposition.position -> float -> (float * float) list -> 'a -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Scale the contents of a page by a given factor centred around a given point in a given range. *)
|
2021-08-12 21:38:55 +02:00
|
|
|
val scale_contents : ?fast:bool -> Cpdfposition.position -> float -> Pdf.t -> int list -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2020-11-12 16:16:58 +01:00
|
|
|
val trim_marks : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
|
|
|
val show_boxes : ?fast:bool -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** {2 Imposition} *)
|
|
|
|
|
2021-10-19 17:18:15 +02:00
|
|
|
val impose : x:float -> y:float -> fit:bool -> columns:bool -> rtl:bool -> btt:bool -> center:bool -> margin:float -> spacing:float -> linewidth:float -> fast:bool -> Pdf.t -> Pdf.t
|
|
|
|
|
2013-08-28 17:31:38 +02:00
|
|
|
(** The twoup_stack operation puts two logical pages on each physical page,
|
2019-07-08 16:13:34 +02:00
|
|
|
rotating them 90 degrees to do so. The new mediabox is thus larger. Bool true
|
|
|
|
(fast) if assume well-formed ISO content streams. *)
|
|
|
|
val twoup_stack : bool -> Pdf.t -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-28 17:31:38 +02:00
|
|
|
(** The twoup operation does the same, but scales the new sides down so that
|
2019-07-08 16:13:34 +02:00
|
|
|
the media box is unchanged. Bool true (fast) if assume well-formed ISO content streams. *)
|
|
|
|
val twoup : bool -> Pdf.t -> Pdf.t
|
2013-08-28 17:31:38 +02:00
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** {2 Miscellany} *)
|
|
|
|
|
|
|
|
(** Make all lines in the PDF at least a certain thickness. *)
|
2013-08-20 16:32:57 +02:00
|
|
|
val thinlines : int list -> float -> Pdf.t -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Make all text on certain pages black. *)
|
2021-12-21 15:00:58 +01:00
|
|
|
val blacktext : Cpdfaddtext.color -> int list -> Pdf.t -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Make all lines on certain pages black. *)
|
2021-12-21 15:00:58 +01:00
|
|
|
val blacklines : Cpdfaddtext.color -> int list -> Pdf.t -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(** Make all fills on certain pages black. *)
|
2021-12-21 15:00:58 +01:00
|
|
|
val blackfills : Cpdfaddtext.color -> int list -> Pdf.t -> Pdf.t
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2020-11-14 17:40:01 +01:00
|
|
|
val remove_all_text : int list -> Pdf.t -> Pdf.t
|
|
|
|
|
2013-08-27 18:35:16 +02:00
|
|
|
(**/**)
|
2013-08-20 16:32:57 +02:00
|
|
|
|
2017-01-10 20:52:57 +01:00
|
|
|
val process_xobjects : Pdf.t -> Pdfpage.t -> (Pdf.t -> Pdf.pdfobject -> Pdf.pdfobject list -> Pdf.pdfobject list) -> unit
|
|
|
|
|
2019-10-02 14:41:56 +02:00
|
|
|
val append_page_content : string -> bool -> bool -> int list -> Pdf.t -> Pdf.t
|
|
|
|
|
2020-03-19 17:23:16 +01:00
|
|
|
val stamp_as_xobject : Pdf.t -> int list -> Pdf.t -> Pdf.t * string
|
2020-03-18 18:08:30 +01:00
|
|
|
|
2021-10-29 16:09:21 +02:00
|
|
|
val remove_dict_entry : Pdf.t -> string -> Pdf.pdfobject option -> unit
|
2020-11-14 17:40:01 +01:00
|
|
|
|
2021-10-29 16:09:21 +02:00
|
|
|
val replace_dict_entry : Pdf.t -> string -> Pdf.pdfobject -> Pdf.pdfobject option -> unit
|
|
|
|
|
|
|
|
val print_dict_entry : Pdf.t -> string -> unit
|
2021-10-28 18:06:46 +02:00
|
|
|
|
2020-11-14 17:40:01 +01:00
|
|
|
val remove_clipping : Pdf.t -> int list -> Pdf.t
|
2020-11-25 17:54:15 +01:00
|
|
|
|
2021-11-12 23:50:31 +01:00
|
|
|
val copy_box : string -> string -> bool -> Pdf.t -> int list -> Pdf.t
|
|
|
|
|
|
|
|
val remove_unused_resources : Pdf.t -> Pdf.t
|