Read-only representation of a PDF document.
Summary
Functions
Authenticates against the document's encryption with the given password.
Same as authenticate/2 but raises on error.
Returns whether the PDF document is encrypted.
Opens a PDF document from the given binary data.
Opens a PDF document from the given binary data, raising an error if it fails.
Returns whether the PDF document is a Tagged PDF with a structure tree.
Opens a PDF document from the specified file path.
Opens a PDF document from the specified file path, raising an error if it fails.
Returns a lazy handle for the page at the given zero-based index.
Same as page/2 but raises an error if it fails.
Returns the number of pages in the given PDF document.
Returns the number of pages in the given PDF document, raising an error if it fails.
Returns a lazy handle for every page in the document.
Returns the file path from which the document was loaded, or nil if it was loaded from binary data.
Extracts the text content of the whole document.
Extracts the text content of the page at the given zero-based index.
Extracts the text content of the whole document, raising an error if it fails.
Extracts the text content of the page at the given zero-based index, raising an error if it fails.
Extracts the text lines of the whole document.
Extracts the text lines of the page at the given zero-based index.
Extracts the text lines of the whole document, raising an error if it fails.
Extracts the text lines of the page at the given zero-based index, raising an error if it fails.
Returns the PDF specification version of the given document as a {major, minor} tuple.
Extracts the words of the whole document.
Extracts the words of the page at the given zero-based index.
Extracts the words of the whole document, raising an error if it fails.
Extracts the words of the page at the given zero-based index, raising an error if it fails.
Types
@type open_opts() :: [{:password, String.t()}]
Options accepted by open/2, open!/2, from_binary/2, and from_binary!/2.
:password— password used to authenticate against an encrypted PDF. When the password is wrong, the call returns{:error, "Authentication failed: wrong password"}(or raises, for the bang variants). When omitted ornil, no authentication attempt is made beyondpdf_oxide's built-in empty-password try.
@type t() :: %PdfElixide.Document{ ref: reference(), source_path: Path.t() | nil, version: {non_neg_integer(), non_neg_integer()} }
Functions
Authenticates against the document's encryption with the given password.
Returns {:ok, true} if authentication succeeded (or the PDF is not encrypted),
{:ok, false} if the password was wrong, or {:error, reason} on a PDF/crypto error.
Same as authenticate/2 but raises on error.
Still returns false (does not raise) for a wrong password.
Returns whether the PDF document is encrypted.
Opens a PDF document from the given binary data.
Opens a PDF document from the given binary data, raising an error if it fails.
Returns whether the PDF document is a Tagged PDF with a structure tree.
Opens a PDF document from the specified file path.
Opens a PDF document from the specified file path, raising an error if it fails.
@spec page(t(), non_neg_integer()) :: {:ok, PdfElixide.Document.Page.t()} | {:error, term()}
Returns a lazy handle for the page at the given zero-based index.
@spec page!(t(), non_neg_integer()) :: PdfElixide.Document.Page.t()
Same as page/2 but raises an error if it fails.
@spec page_count(t()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the number of pages in the given PDF document.
@spec page_count!(t()) :: non_neg_integer()
Returns the number of pages in the given PDF document, raising an error if it fails.
@spec pages(t()) :: [PdfElixide.Document.Page.t()]
Returns a lazy handle for every page in the document.
Returns the file path from which the document was loaded, or nil if it was loaded from binary data.
Extracts the text content of the whole document.
Returns every page's text concatenated in order, separated by a form-feed
(\f) page separator.
@spec text(t(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}
Extracts the text content of the page at the given zero-based index.
Extracts the text content of the whole document, raising an error if it fails.
@spec text!(t(), non_neg_integer()) :: binary()
Extracts the text content of the page at the given zero-based index, raising an error if it fails.
@spec text_lines(t()) :: {:ok, [PdfElixide.Document.TextLine.t()]} | {:error, term()}
Extracts the text lines of the whole document.
Returns every page's lines concatenated into a single flat list, in page
order. Each line carries its bounding box and constituent words as a
PdfElixide.Document.TextLine struct.
@spec text_lines(t(), non_neg_integer()) :: {:ok, [PdfElixide.Document.TextLine.t()]} | {:error, term()}
Extracts the text lines of the page at the given zero-based index.
Each line carries its bounding box and constituent words as a
PdfElixide.Document.TextLine struct.
@spec text_lines!(t()) :: [PdfElixide.Document.TextLine.t()]
Extracts the text lines of the whole document, raising an error if it fails.
@spec text_lines!(t(), non_neg_integer()) :: [PdfElixide.Document.TextLine.t()]
Extracts the text lines of the page at the given zero-based index, raising an error if it fails.
@spec version(t()) :: {non_neg_integer(), non_neg_integer()}
Returns the PDF specification version of the given document as a {major, minor} tuple.
@spec words(t()) :: {:ok, [PdfElixide.Document.Word.t()]} | {:error, term()}
Extracts the words of the whole document.
Returns every page's words concatenated into a single flat list, in page
order. Each word carries its bounding box and font metadata as a
PdfElixide.Document.Word struct.
@spec words(t(), non_neg_integer()) :: {:ok, [PdfElixide.Document.Word.t()]} | {:error, term()}
Extracts the words of the page at the given zero-based index.
Each word carries its bounding box and font metadata as a
PdfElixide.Document.Word struct.
@spec words!(t()) :: [PdfElixide.Document.Word.t()]
Extracts the words of the whole document, raising an error if it fails.
@spec words!(t(), non_neg_integer()) :: [PdfElixide.Document.Word.t()]
Extracts the words of the page at the given zero-based index, raising an error if it fails.