Representation of a page of a PDF document.
Summary
Functions
Reads the annotations on the page.
Same as annotations/1 but raises an error if it fails.
Extracts the characters of the page, each with its bounding box, font metadata, and typographic placement.
Same as chars/2 but raises an error if it fails.
Extracts the fonts referenced by the page.
Same as fonts/1 but raises an error if it fails.
Returns the page's height in points.
Same as height/1 but raises an error if it fails.
Extracts the raster images of the page — photos, logos, and scanned pictures.
Same as images/1 but raises an error if it fails.
Returns the page's logical page label (e.g. "i", "1", "A-1").
Same as label/1 but raises an error if it fails.
Extracts the vector paths of the page — lines, curves, rectangles, and shapes.
Same as paths/1 but raises an error if it fails.
Extracts the spans of the page, each a run of text sharing one text state.
Same as spans/2 but raises an error if it fails.
Detects the tables of the page.
Same as tables/2 but raises an error if it fails.
Extracts the text content of the page.
Same as text/2 but raises an error if it fails.
Extracts the text lines of the page, each with its bounding box and words.
Same as text_lines/2 but raises an error if it fails.
Converts the page to an HTML fragment.
Same as to_html/2 but raises an error if it fails.
Converts the page to Markdown.
Same as to_markdown/2 but raises an error if it fails.
Returns the page's width in points.
Same as width/1 but raises an error if it fails.
Extracts the words of the page, each with its bounding box and font metadata.
Same as words/2 but raises an error if it fails.
Types
@type t() :: %PdfElixide.Document.Page{ doc: PdfElixide.Document.t(), index: non_neg_integer() }
Functions
@spec annotations(t()) :: {:ok, [PdfElixide.Document.Annotation.t()]} | {:error, PdfElixide.Error.t()}
Reads the annotations on the page.
Returns {:ok, []} when the page has no annotations.
@spec annotations!(t()) :: [PdfElixide.Document.Annotation.t()]
Same as annotations/1 but raises an error if it fails.
@spec chars(t(), PdfElixide.Document.chars_opts()) :: {:ok, [PdfElixide.Document.Char.t()]} | {:error, PdfElixide.Error.t()}
Extracts the characters of the page, each with its bounding box, font metadata, and typographic placement.
See PdfElixide.Document.chars_opts/0 for the available options.
@spec chars!(t(), PdfElixide.Document.chars_opts()) :: [PdfElixide.Document.Char.t()]
Same as chars/2 but raises an error if it fails.
@spec fonts(t()) :: {:ok, [PdfElixide.Document.Font.t()]} | {:error, PdfElixide.Error.t()}
Extracts the fonts referenced by the page.
Returns {:ok, []} when the page references no fonts — and also when the page
or its /Resources could not be read, which PdfElixide.Document.fonts/2
explains.
@spec fonts!(t()) :: [PdfElixide.Document.Font.t()]
Same as fonts/1 but raises an error if it fails.
@spec height(t()) :: {:ok, float()} | {:error, PdfElixide.Error.t()}
Returns the page's height in points.
Same as height/1 but raises an error if it fails.
@spec images(t()) :: {:ok, [PdfElixide.Document.Image.t()]} | {:error, PdfElixide.Error.t()}
Extracts the raster images of the page — photos, logos, and scanned pictures.
Returns {:ok, []} when the page has no images.
@spec images!(t()) :: [PdfElixide.Document.Image.t()]
Same as images/1 but raises an error if it fails.
@spec label(t()) :: {:ok, String.t()} | {:error, PdfElixide.Error.t()}
Returns the page's logical page label (e.g. "i", "1", "A-1").
This is the human-facing page number the PDF may define, independent of the zero-based physical index. Pages outside any declared label range fall back to their decimal page number.
A page whose :index is not a page of the document — only reachable from a
hand-built or stale %Page{} — yields %PdfElixide.Error{reason: :out_of_range}.
Every call re-reads the document's label ranges, so use
PdfElixide.Document.page_labels/1 to label a whole document.
Same as label/1 but raises an error if it fails.
@spec paths(t()) :: {:ok, [PdfElixide.Document.Path.t()]} | {:error, PdfElixide.Error.t()}
Extracts the vector paths of the page — lines, curves, rectangles, and shapes.
Returns {:ok, []} when the page has no vector graphics.
@spec paths!(t()) :: [PdfElixide.Document.Path.t()]
Same as paths/1 but raises an error if it fails.
@spec spans(t(), PdfElixide.Document.spans_opts()) :: {:ok, [PdfElixide.Document.Span.t()]} | {:error, PdfElixide.Error.t()}
Extracts the spans of the page, each a run of text sharing one text state.
See PdfElixide.Document.spans_opts/0 for the available options.
@spec spans!(t(), PdfElixide.Document.spans_opts()) :: [PdfElixide.Document.Span.t()]
Same as spans/2 but raises an error if it fails.
@spec tables(t(), PdfElixide.Document.tables_opts()) :: {:ok, [PdfElixide.Document.Table.t()]} | {:error, PdfElixide.Error.t()}
Detects the tables of the page.
Returns {:ok, []} when the page has no detectable table. See
PdfElixide.Document.tables_opts/0 for the available options.
@spec tables!(t(), PdfElixide.Document.tables_opts()) :: [ PdfElixide.Document.Table.t() ]
Same as tables/2 but raises an error if it fails.
@spec text(t(), PdfElixide.Document.text_opts()) :: {:ok, String.t()} | {:error, PdfElixide.Error.t()}
Extracts the text content of the page.
A page that cannot be extracted is an error here, where
PdfElixide.Document.text/1 skips it by default — :on_page_error is a
whole-document option and does nothing on this path.
See PdfElixide.Document.text_opts/0 for the available options.
@spec text!(t(), PdfElixide.Document.text_opts()) :: String.t()
Same as text/2 but raises an error if it fails.
@spec text_lines(t(), PdfElixide.Document.text_lines_opts()) :: {:ok, [PdfElixide.Document.TextLine.t()]} | {:error, PdfElixide.Error.t()}
Extracts the text lines of the page, each with its bounding box and words.
See PdfElixide.Document.text_lines_opts/0 for the available options.
@spec text_lines!(t(), PdfElixide.Document.text_lines_opts()) :: [ PdfElixide.Document.TextLine.t() ]
Same as text_lines/2 but raises an error if it fails.
@spec to_html(t(), PdfElixide.Document.html_opts()) :: {:ok, String.t()} | {:error, PdfElixide.Error.t()}
Converts the page to an HTML fragment.
See PdfElixide.Document.html_opts/0 for the available options.
@spec to_html!(t(), PdfElixide.Document.html_opts()) :: String.t()
Same as to_html/2 but raises an error if it fails.
@spec to_markdown(t(), PdfElixide.Document.markdown_opts()) :: {:ok, String.t()} | {:error, PdfElixide.Error.t()}
Converts the page to Markdown.
See PdfElixide.Document.markdown_opts/0 for the available options.
@spec to_markdown!(t(), PdfElixide.Document.markdown_opts()) :: String.t()
Same as to_markdown/2 but raises an error if it fails.
@spec width(t()) :: {:ok, float()} | {:error, PdfElixide.Error.t()}
Returns the page's width in points.
Same as width/1 but raises an error if it fails.
@spec words(t(), PdfElixide.Document.words_opts()) :: {:ok, [PdfElixide.Document.Word.t()]} | {:error, PdfElixide.Error.t()}
Extracts the words of the page, each with its bounding box and font metadata.
See PdfElixide.Document.words_opts/0 for the available options.
@spec words!(t(), PdfElixide.Document.words_opts()) :: [PdfElixide.Document.Word.t()]
Same as words/2 but raises an error if it fails.