Module PDF.Document

PDF documents.

type t = {PDF}1.document
val create : unit -> t
val open_document : string -> t

Open a PDF document.

Open a PDF document by reading its cross reference table, so MuPDF can locate PDF objects inside the file. Upon an broken cross reference table or other parse errors MuPDF will restart parsing the file from the beginning to try to rebuild a (hopefully correct) cross reference table to allow further processing of the file.

The returned pdf_document should be used when calling most other PDF functions. Note that it wraps the context, so those functions implicitly get access to the global state in context.

val close : t -> unit

Close document.

val save : t -> string -> unit

Write out the document to a file with all changes finalised.

val count_pages : t -> int

Count number of pages.

val delete_page : t -> int -> unit

Delete a page from the page tree of a document. This does not remove the page contents or resources from the file.

val delete_page_range : t -> int -> int -> unit

Delete a range of pages from the page tree of a document. This does not remove the page contents or resources from the file.

val graft_page : t -> int -> t -> int -> unit

Graft a page (and its resources) from the src document to the destination document of the graft. This involves a deep copy of the objects in question.

val minimize : t -> unit

Minimize the memory used by a document.

We walk the in memory xref tables, evicting the PDF objects therein that aren't in use.

This reduces the current memory use, but any subsequent use of these objects will load them back into memory again.