Skip to main content

PdfDevice

Struct PdfDevice 

Source
pub struct PdfDevice { /* private fields */ }
Expand description

PDF output device. Accumulates display lists per page and generates a single PDF file containing all pages on finish().

Implementations§

Source§

impl PdfDevice

Source

pub fn new(width: u32, height: u32, dpi: f64) -> Self

Create a new PDF device with the given page dimensions and DPI.

Source

pub fn set_emit_page_box_clip(&mut self, on: bool)

Control whether to emit the implicit 0 0 W H re W n page-box clip at the top of each content stream. Default true; PDF→PDF round-trip should set this to false so the writer faithfully reproduces the source content without injecting a top-level clip.

Source

pub fn set_output_intents(&mut self, intents: Vec<OutputIntentRecord>)

Set the /Catalog /OutputIntents chain to emit. Replaces any previously installed records. Used by PDF→PDF round-trip to carry the source PDF’s PDF/X / PDF/A OutputIntent over to the output; preserving this lets the renderer route DeviceGray / DeviceCMYK / ICCBased fills through the same destination profile the source declared, so a re-rendered output PDF colour-matches the input.

Source

pub fn set_trim_box(&mut self, llx: f64, lly: f64, urx: f64, ury: f64)

Set the trim box for the next page (in PDF points, lower-left origin).

Source

pub fn set_page_size(&mut self, width: u32, height: u32)

Set the page dimensions used for the next page. The PS interpreter path drives this implicitly through setpagedevice + device-factory re-creation; direct API users (e.g. PDF→PDF rewriting) call this before each replay_and_show so per-page sizes can vary across pages in the same output PDF.

Source

pub fn set_output_profile(&mut self, bytes: Vec<u8>)

👎Deprecated:

OutputIntent emission is temporarily disabled pending PDF/X-4 support; calling this has no effect

Set an ICC output profile.

Previously embedded as a PDF/X-3 OutputIntent, but the emitted output contained transparency features (soft masks) that PDF/X-3 prohibits. The OutputIntent emission path has been removed pending a correct PDF/X-4 implementation; calling this currently has no effect on the output. The setter is retained so the API is forward-compatible with the eventual X-4 work.

Source

pub fn take_pdf_bytes(&self) -> Option<Vec<u8>>

Build the PDF document into a byte vector.

Returns the complete PDF file contents. The device must have at least one page (call after finish() or finish_with_context()).

Source

pub fn take_pdf_bytes_with_context(&self, ctx: &Context) -> Option<Vec<u8>>

Build the PDF document into a byte vector, using Context for font data.

Source

pub fn set_output_path(&mut self, path: impl Into<String>)

Pin the file this device writes at end of job.

Set from an explicit --output path so the name is used verbatim, instead of being derived in Self::replay_and_show from the per-page name the interpreter passes down.

Trait Implementations§

Source§

impl OutputDevice for PdfDevice

Source§

fn writes_file_per_page(&self) -> bool

Every page accumulates into one PDF, written at end of job, so a single output name serves a multi-page document.

Source§

fn fill_path(&mut self, _path: &PsPath, _params: &FillParams)

Fill a path with the given color.
Source§

fn stroke_path(&mut self, _path: &PsPath, _params: &StrokeParams)

Stroke a path with the given parameters.
Source§

fn clip_path(&mut self, _path: &PsPath, _params: &ClipParams)

Intersect the current clip region with the given path.
Source§

fn init_clip(&mut self)

Reset clipping to the full page.
Source§

fn erase_page(&mut self)

Erase the page (fill with white).
Source§

fn set_trim_box(&mut self, llx: f64, lly: f64, urx: f64, ury: f64)

Set the trim box for the next page (PDF points, lower-left origin). Only meaningful for PDF output; other devices ignore this.
Source§

fn show_page(&mut self, _output_path: &str) -> Result<(), String>

Output the current page (e.g., save PNG) and return Ok/Err.
Source§

fn draw_image(&mut self, _sample_data: &[u8], _params: &ImageParams)

Draw an image from raw sample data.
Source§

fn page_size(&self) -> (u32, u32)

Page dimensions in device pixels.
Source§

fn replay_and_show( &mut self, list: DisplayList, output_path: &str, ) -> Result<(), String>

Replay a display list and write output in one step.
Source§

fn finish(&mut self) -> Result<(), String>

Wait for any pending background render to complete.
Source§

fn finish_with_context(&mut self, ctx: &Context) -> Result<(), String>

Called after interpretation finishes, with access to the interpreter context.
Source§

fn as_any(&self) -> &dyn Any

Downcast to a concrete type. Override in implementations that need to be accessed after rendering (e.g., PdfDevice for in-memory output).
Source§

fn paint_axial_shading(&mut self, _params: &AxialShadingParams)

Paint an axial (linear) gradient shading.
Source§

fn paint_radial_shading(&mut self, _params: &RadialShadingParams)

Paint a radial gradient shading.
Source§

fn paint_mesh_shading(&mut self, _params: &MeshShadingParams)

Paint a Gouraud-shaded triangle mesh.
Source§

fn paint_patch_shading(&mut self, _params: &PatchShadingParams)

Paint a Coons/tensor-product patch mesh.
Source§

fn paint_pattern_fill(&mut self, _params: &PatternFillParams)

Paint a tiled pattern fill.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.