Kreuzberg.Page (kreuzberg v4.0.8)
View SourceStructure representing a single page extracted from a multi-page document.
Contains page-specific content, dimensions, and metadata when page-level extraction is enabled.
Fields
:number- Page number (1-indexed):content- Text content extracted from this page:width- Page width in inches or centimeters:height- Page height in inches or centimeters:index- Zero-indexed page index (alternative to number)
Examples
iex> page = %Kreuzberg.Page{
...> number: 1,
...> content: "Page 1 content here",
...> width: 8.5,
...> height: 11.0
...> }
iex> page.number
1
iex> page.content
"Page 1 content here"
Summary
Functions
Creates a Page struct from a map.
Creates a new Page struct with required number and content.
Returns the page size as a {width, height} tuple.
Converts a Page struct to a map.
Types
Functions
Creates a Page struct from a map.
Converts a plain map (typically from NIF/Rust) into a proper struct.
Parameters
data- A map containing page fields
Returns
A Page struct with matching fields populated.
Examples
iex> page_map = %{
...> "number" => 1,
...> "content" => "Page text",
...> "width" => 8.5
...> }
iex> Kreuzberg.Page.from_map(page_map)
%Kreuzberg.Page{
number: 1,
content: "Page text",
width: 8.5
}
Creates a new Page struct with required number and content.
Parameters
number- The page number (1-indexed)content- The text content of the pageopts- Optional keyword list with::width- Page width:height- Page height:index- Zero-indexed page index
Returns
A Page struct with the provided number, content, and options.
Examples
iex> Kreuzberg.Page.new(1, "Page content")
%Kreuzberg.Page{number: 1, content: "Page content"}
iex> Kreuzberg.Page.new(
...> 2,
...> "More content",
...> width: 8.5,
...> height: 11.0
...> )
%Kreuzberg.Page{
number: 2,
content: "More content",
width: 8.5,
height: 11.0
}
Returns the page size as a {width, height} tuple.
Useful for layout calculations and image sizing.
Parameters
page- APagestruct
Returns
A tuple {width, height} or nil if dimensions not available.
Examples
iex> page = %Kreuzberg.Page{width: 8.5, height: 11.0}
iex> Kreuzberg.Page.size(page)
{8.5, 11.0}
iex> page = %Kreuzberg.Page{number: 1}
iex> Kreuzberg.Page.size(page)
nil
Converts a Page struct to a map.
Useful for serialization and passing to external systems.
Parameters
page- APagestruct
Returns
A map with string keys representing all fields.
Examples
iex> page = %Kreuzberg.Page{number: 1, content: "text", width: 8.5}
iex> Kreuzberg.Page.to_map(page)
%{
"number" => 1,
"content" => "text",
"width" => 8.5,
...
}