PdfElixide.Document.RenderedPage (pdf_elixide v0.23.0)

Copy Markdown View Source

A page rasterized to an image, with the encoded bytes and their pixel dimensions.

page = PdfElixide.Document.page!(doc, 0)
rendered = PdfElixide.Document.Page.render!(page, dpi: 150)

File.write!("page0.png", rendered.data)
{rendered.width, rendered.height}
#=> {1275, 1650}

:data is a complete file for :png and :jpeg. For :rgba8 it is bare pixels instead — premultiplied RGBA8888, four bytes per pixel, row-major from the top-left corner, with no padding between rows, so byte_size(data) == width * height * 4. Un-premultiply it yourself if you need straight alpha.

Unlike PdfElixide.Document.Image, this struct holds no native handle: the bytes are already encoded, so there is nothing to release and nothing to close.

See the Rendering guide for what the raster covers, how to size it, and how layer visibility differs from text extraction.

Summary

Types

The encoding of :data — the :format the render was asked for.

t()

Types

format()

@type format() :: :png | :jpeg | :rgba8

The encoding of :data — the :format the render was asked for.

t()

@type t() :: %PdfElixide.Document.RenderedPage{
  data: binary(),
  format: format(),
  height: non_neg_integer(),
  width: non_neg_integer()
}