Skip to main content

render_page_to_device

Function render_page_to_device 

Source
pub fn render_page_to_device<B: RasterBackend>(
    page: &Page,
    opts: &RenderOptions,
    backend: &B,
    diags: &mut Diagnostics,
) -> Result<B::Device, Error>
Expand description

Record a page onto a backend device without rasterizing the root target.

Same walk as render_page, but the caller owns the device afterwards: a GPU embedder dispatches it into a texture with VelloBackend::render_to_view and never reads pixels; a CPU caller still calls RasterBackend::finish. Offscreen finish calls inside the walk — groups, masks, pattern cells — are unchanged.

use pdfrum_common::Diagnostics;
use pdfrum_page::Page;
use pdfrum_raster_tinyskia::TinySkiaBackend;
use pdfrum_render::{RasterBackend, RenderOptions, render_page_to_device};

let backend = TinySkiaBackend;
let device = render_page_to_device(
    &Page::empty(),
    &RenderOptions::default(),
    &backend,
    &mut Diagnostics::default(),
)?;
let pixmap = backend.finish(device);
assert_eq!((pixmap.width(), pixmap.height()), (612, 792));

§Errors

As render_page.