v2.6 documentation

This commit is contained in:
John Whitington 2023-07-27 13:21:15 +01:00
parent 7fc9bea729
commit 057434fb6a
7 changed files with 28 additions and 15 deletions

View File

@ -45,6 +45,19 @@ val addtexts :
Pdf.t ->(*pdf*) Pdf.t ->(*pdf*)
Pdf.t Pdf.t
(** Add a rectangle to the given pages. [addrectangle fast (w, h) colour outline linewidth opacity position relative_to_cropbox underneath range pdf]. *)
val addrectangle :
bool ->
float * float ->
color ->
bool ->
float ->
float ->
Cpdfposition.position ->
bool -> bool -> int list -> Pdf.t -> Pdf.t
(**/**)
val replace_pairs : val replace_pairs :
Pdf.t -> Pdf.t ->
int -> int ->
@ -56,13 +69,3 @@ val replace_pairs :
val process_text : val process_text :
Cpdfstrftime.t -> string -> (string * (unit -> string)) list -> string Cpdfstrftime.t -> string -> (string * (unit -> string)) list -> string
(* Add a rectangle to the page *)
val addrectangle :
bool ->
float * float ->
color ->
bool ->
float ->
float ->
Cpdfposition.position ->
bool -> bool -> int list -> Pdf.t -> Pdf.t

View File

@ -4483,7 +4483,7 @@ let go () =
let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in
write_pdf write_pdf
false false
(Cpdfdraw.draw ~fast:args.fast ~filename:args.original_filename ~bates:args.bates ~batespad:args.batespad args.fast range pdf ops) (Cpdfdraw.draw ~fast:args.fast ~underneath:args.underneath ~filename:args.original_filename ~bates:args.bates ~batespad:args.batespad range pdf ops)
| Some (Composition json) -> | Some (Composition json) ->
let pdf = get_single_pdf args.op false in let pdf = get_single_pdf args.op false in
let filesize = let filesize =

View File

@ -420,7 +420,7 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
in in
Pdfpage.change_pages true pdf pages Pdfpage.change_pages true pdf pages
let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad fast range pdf drawops = let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad range pdf drawops =
(*Printf.printf "%s\n" (string_of_drawops drawops); *) (*Printf.printf "%s\n" (string_of_drawops drawops); *)
resstack := [empty_res ()]; resstack := [empty_res ()];
Hashtbl.clear !fontpacks; Hashtbl.clear !fontpacks;

View File

@ -1,3 +1,5 @@
(** Draw on PDFs *)
type colspec = type colspec =
NoCol NoCol
| RGB of float * float * float | RGB of float * float * float
@ -48,9 +50,11 @@ type drawops =
| RenderMode of int | RenderMode of int
| Rise of float | Rise of float
(** Calling [draw fast underneath filename bates batespad range pdf drawops] draws on
top of all the pages in the range. *)
val draw : ?fast:bool -> val draw : ?fast:bool ->
?underneath:bool -> ?underneath:bool ->
filename:string -> filename:string ->
bates:int -> bates:int ->
batespad:int option -> batespad:int option ->
bool -> int list -> Pdf.t -> drawops list -> Pdf.t int list -> Pdf.t -> drawops list -> Pdf.t

View File

@ -3,13 +3,14 @@
(** Write a PDF in CPDFJSON format. [parse_content] parses page content (** Write a PDF in CPDFJSON format. [parse_content] parses page content
streams, [no_stream_data] will omit stream data, [decompress_streams] streams, [no_stream_data] will omit stream data, [decompress_streams]
decompresses all streams, [clean_strings] will convert any UTF16BE strings decompresses all streams, [clean_strings] will convert any UTF16BE strings
to PDFDocEncoding if it can. *) to PDFDocEncoding if it can. If [utf8] is set, CPDFJSON UTF8 format is used
instead. *)
val to_output : Pdfio.output -> utf8:bool -> parse_content:bool -> no_stream_data:bool -> decompress_streams:bool -> ?clean_strings:bool -> Pdf.t -> unit val to_output : Pdfio.output -> utf8:bool -> parse_content:bool -> no_stream_data:bool -> decompress_streams:bool -> ?clean_strings:bool -> Pdf.t -> unit
(** Read a CPDFJSON PDF from an input. /Length entries will be corrected automatically. *) (** Read a CPDFJSON PDF from an input. /Length entries will be corrected automatically. *)
val of_input : Pdfio.input -> Pdf.t val of_input : Pdfio.input -> Pdf.t
(** Convert a single PDF object to CPDFJSON format. [clean_strings] is as above. (** Convert a single PDF object to CPDFJSON format. [clean_strings] and [utf8] are as above.
Then the PDF file, then a function which is usually [function _ -> ()], then Then the PDF file, then a function which is usually [function _ -> ()], then
[no_stream_data] as above, then [parse_content_streams] as above, and [no_stream_data] as above, then [parse_content_streams] as above, and
finally the object itself. *) finally the object itself. *)

View File

@ -4,6 +4,7 @@
{ul {ul
{- Page numbers can be given plain, like 1 or 2, or as page labels, like <1> or <iii> (backslash to escape intended angle bracket)} {- Page numbers can be given plain, like 1 or 2, or as page labels, like <1> or <iii> (backslash to escape intended angle bracket)}
{- A page label may be used in place of a number e.g [[iii]] represents the first page found which is labelled [iii]. }
{- A dash (-) defines ranges e.g 1-5 or 6-3.} {- A dash (-) defines ranges e.g 1-5 or 6-3.}
{- A comma (,) allows one to specify several ranges, e.g. 1-2,4-5.} {- A comma (,) allows one to specify several ranges, e.g. 1-2,4-5.}
{- The word end represents the last page number.} {- The word end represents the last page number.}

View File

@ -12,10 +12,14 @@ type element =
type t = element list type t = element list
(** Debug printing *)
val to_string : t -> string val to_string : t -> string
(** Return the font width table for a given (id, font, fontsize) combination. *)
val font_widths : string -> Pdftext.font -> float -> float array val font_widths : string -> Pdftext.font -> float -> float array
(** Calculate the widths of a string given a font width table, and list of char codes *)
val width_of_string : float array -> char list -> float val width_of_string : float array -> char list -> float
(** [typeset lmargin rmargin tmargin bmargin papersize pdf contents] builds a list of pages of typset content. *)
val typeset : float -> float -> float -> float -> Pdfpaper.t -> Pdf.t -> t -> Pdfpage.t list val typeset : float -> float -> float -> float -> Pdfpaper.t -> Pdf.t -> t -> Pdfpage.t list