GraphicsContext

Struct GraphicsContext 

Source
pub struct GraphicsContext { /* private fields */ }

Implementations§

Source§

impl GraphicsContext

Source

pub fn new() -> Self

Source

pub fn move_to(&mut self, x: f64, y: f64) -> &mut Self

Source

pub fn line_to(&mut self, x: f64, y: f64) -> &mut Self

Source

pub fn curve_to( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64, ) -> &mut Self

Source

pub fn rect(&mut self, x: f64, y: f64, width: f64, height: f64) -> &mut Self

Source

pub fn circle(&mut self, cx: f64, cy: f64, radius: f64) -> &mut Self

Source

pub fn close_path(&mut self) -> &mut Self

Source

pub fn stroke(&mut self) -> &mut Self

Source

pub fn fill(&mut self) -> &mut Self

Source

pub fn fill_stroke(&mut self) -> &mut Self

Source

pub fn set_stroke_color(&mut self, color: Color) -> &mut Self

Source

pub fn set_fill_color(&mut self, color: Color) -> &mut Self

Source

pub fn set_fill_color_calibrated(&mut self, color: CalibratedColor) -> &mut Self

Set fill color using calibrated color space

Source

pub fn set_stroke_color_calibrated( &mut self, color: CalibratedColor, ) -> &mut Self

Set stroke color using calibrated color space

Source

pub fn set_fill_color_lab(&mut self, color: LabColor) -> &mut Self

Set fill color using Lab color space

Source

pub fn set_stroke_color_lab(&mut self, color: LabColor) -> &mut Self

Set stroke color using Lab color space

Source

pub fn set_line_width(&mut self, width: f64) -> &mut Self

Source

pub fn set_line_cap(&mut self, cap: LineCap) -> &mut Self

Source

pub fn set_line_join(&mut self, join: LineJoin) -> &mut Self

Source

pub fn set_opacity(&mut self, opacity: f64) -> &mut Self

Set the opacity for both fill and stroke operations (0.0 to 1.0)

Source

pub fn set_fill_opacity(&mut self, opacity: f64) -> &mut Self

Set the fill opacity (0.0 to 1.0)

Source

pub fn set_stroke_opacity(&mut self, opacity: f64) -> &mut Self

Set the stroke opacity (0.0 to 1.0)

Source

pub fn save_state(&mut self) -> &mut Self

Source

pub fn restore_state(&mut self) -> &mut Self

Source

pub fn begin_transparency_group( &mut self, group: TransparencyGroup, ) -> &mut Self

Begin a transparency group ISO 32000-1:2008 Section 11.4

Source

pub fn end_transparency_group(&mut self) -> &mut Self

End a transparency group

Source

pub fn in_transparency_group(&self) -> bool

Check if we’re currently inside a transparency group

Source

pub fn current_transparency_group(&self) -> Option<&TransparencyGroup>

Get the current transparency group (if any)

Source

pub fn translate(&mut self, tx: f64, ty: f64) -> &mut Self

Source

pub fn scale(&mut self, sx: f64, sy: f64) -> &mut Self

Source

pub fn rotate(&mut self, angle: f64) -> &mut Self

Source

pub fn transform( &mut self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, ) -> &mut Self

Source

pub fn rectangle( &mut self, x: f64, y: f64, width: f64, height: f64, ) -> &mut Self

Source

pub fn draw_image( &mut self, image_name: &str, x: f64, y: f64, width: f64, height: f64, ) -> &mut Self

Source

pub fn draw_image_with_transparency( &mut self, image_name: &str, x: f64, y: f64, width: f64, height: f64, mask_name: Option<&str>, ) -> &mut Self

Draw an image with transparency support (soft mask) This method handles images with alpha channels or soft masks

Source

pub fn uses_transparency(&self) -> bool

Check if transparency is used (opacity != 1.0)

Source

pub fn generate_graphics_state_dict(&self) -> Option<String>

Generate the graphics state dictionary for transparency

Source

pub fn fill_color(&self) -> Color

Get the current fill color

Source

pub fn stroke_color(&self) -> Color

Get the current stroke color

Source

pub fn line_width(&self) -> f64

Get the current line width

Source

pub fn fill_opacity(&self) -> f64

Get the current fill opacity

Source

pub fn stroke_opacity(&self) -> f64

Get the current stroke opacity

Source

pub fn operations(&self) -> &str

Get the operations string

Source

pub fn get_operations(&self) -> &str

Get the operations string (alias for testing)

Source

pub fn clear(&mut self)

Clear all operations

Source

pub fn begin_text(&mut self) -> &mut Self

Begin a text object

Source

pub fn end_text(&mut self) -> &mut Self

End a text object

Source

pub fn set_font(&mut self, font: Font, size: f64) -> &mut Self

Set font and size

Source

pub fn set_text_position(&mut self, x: f64, y: f64) -> &mut Self

Set text position

Source

pub fn show_text(&mut self, text: &str) -> Result<&mut Self>

Show text

Source

pub fn set_word_spacing(&mut self, spacing: f64) -> &mut Self

Set word spacing for text justification

Source

pub fn set_character_spacing(&mut self, spacing: f64) -> &mut Self

Set character spacing

Source

pub fn show_justified_text( &mut self, text: &str, target_width: f64, ) -> Result<&mut Self>

Show justified text with automatic word spacing calculation

Source

pub fn render_table(&mut self, table: &Table) -> Result<()>

Render a table

Source

pub fn render_list(&mut self, list: &ListElement) -> Result<()>

Render a list

Source

pub fn render_column_layout( &mut self, layout: &ColumnLayout, content: &ColumnContent, x: f64, y: f64, height: f64, ) -> Result<()>

Render column layout

Source

pub fn set_line_dash_pattern(&mut self, pattern: LineDashPattern) -> &mut Self

Set line dash pattern

Source

pub fn set_line_solid(&mut self) -> &mut Self

Set line dash pattern to solid (no dashes)

Source

pub fn set_miter_limit(&mut self, limit: f64) -> &mut Self

Set miter limit

Source

pub fn set_rendering_intent(&mut self, intent: RenderingIntent) -> &mut Self

Set rendering intent

Source

pub fn set_flatness(&mut self, flatness: f64) -> &mut Self

Set flatness tolerance

Source

pub fn apply_extgstate(&mut self, state: ExtGState) -> Result<&mut Self>

Apply an ExtGState dictionary immediately

Source

pub fn with_extgstate<F>(&mut self, builder: F) -> Result<&mut Self>
where F: FnOnce(ExtGState) -> ExtGState,

Create and apply a custom ExtGState

Source

pub fn set_blend_mode(&mut self, mode: BlendMode) -> Result<&mut Self>

Set blend mode for transparency

Source

pub fn set_alpha(&mut self, alpha: f64) -> Result<&mut Self>

Set alpha for both stroke and fill operations

Source

pub fn set_alpha_stroke(&mut self, alpha: f64) -> Result<&mut Self>

Set alpha for stroke operations only

Source

pub fn set_alpha_fill(&mut self, alpha: f64) -> Result<&mut Self>

Set alpha for fill operations only

Source

pub fn set_overprint_stroke(&mut self, overprint: bool) -> Result<&mut Self>

Set overprint for stroke operations

Source

pub fn set_overprint_fill(&mut self, overprint: bool) -> Result<&mut Self>

Set overprint for fill operations

Source

pub fn set_stroke_adjustment(&mut self, adjustment: bool) -> Result<&mut Self>

Set stroke adjustment

Source

pub fn set_smoothness(&mut self, smoothness: f64) -> Result<&mut Self>

Set smoothness tolerance

Source

pub fn line_dash_pattern(&self) -> Option<&LineDashPattern>

Get current line dash pattern

Source

pub fn miter_limit(&self) -> f64

Get current miter limit

Source

pub fn line_cap(&self) -> LineCap

Get current line cap

Source

pub fn line_join(&self) -> LineJoin

Get current line join

Source

pub fn rendering_intent(&self) -> RenderingIntent

Get current rendering intent

Source

pub fn flatness(&self) -> f64

Get current flatness tolerance

Source

pub fn smoothness(&self) -> f64

Get current smoothness tolerance

Source

pub fn extgstate_manager(&self) -> &ExtGStateManager

Get the ExtGState manager (for advanced usage)

Source

pub fn extgstate_manager_mut(&mut self) -> &mut ExtGStateManager

Get mutable ExtGState manager (for advanced usage)

Source

pub fn generate_extgstate_resources(&self) -> Result<String>

Generate ExtGState resource dictionary for PDF

Source

pub fn has_extgstates(&self) -> bool

Check if any extended graphics states are defined

Source

pub fn add_command(&mut self, command: &str)

Add a command to the operations

Source

pub fn clip(&mut self) -> &mut Self

Create clipping path from current path using non-zero winding rule

Source

pub fn clip_even_odd(&mut self) -> &mut Self

Create clipping path from current path using even-odd rule

Source

pub fn clip_stroke(&mut self) -> &mut Self

Create clipping path and stroke it

Source

pub fn set_clipping_path(&mut self, path: ClippingPath) -> Result<&mut Self>

Set a custom clipping path

Source

pub fn clear_clipping(&mut self) -> &mut Self

Clear the current clipping path

Source

pub fn clip_rect( &mut self, x: f64, y: f64, width: f64, height: f64, ) -> Result<&mut Self>

Create a rectangular clipping region

Source

pub fn clip_circle( &mut self, cx: f64, cy: f64, radius: f64, ) -> Result<&mut Self>

Create a circular clipping region

Source

pub fn clip_ellipse( &mut self, cx: f64, cy: f64, rx: f64, ry: f64, ) -> Result<&mut Self>

Create an elliptical clipping region

Source

pub fn has_clipping(&self) -> bool

Check if a clipping path is active

Source

pub fn clipping_path(&self) -> Option<&ClippingPath>

Get the current clipping path

Source

pub fn set_font_manager(&mut self, font_manager: Arc<FontManager>) -> &mut Self

Set the font manager for custom fonts

Source

pub fn set_custom_font(&mut self, font_name: &str, size: f64) -> &mut Self

Set the current font to a custom font

Source

pub fn set_glyph_mapping(&mut self, mapping: HashMap<u32, u16>) -> &mut Self

Set the glyph mapping for Unicode fonts (Unicode -> GlyphID)

Source

pub fn draw_text(&mut self, text: &str, x: f64, y: f64) -> Result<&mut Self>

Draw text at the specified position with automatic encoding detection

Source

pub fn draw_text_hex(&mut self, text: &str, x: f64, y: f64) -> Result<&mut Self>

👎Deprecated: Use draw_text() which automatically detects encoding

Legacy: Draw text with hex encoding (kept for compatibility)

Source

pub fn draw_text_cid(&mut self, text: &str, x: f64, y: f64) -> Result<&mut Self>

👎Deprecated: Use draw_text() which automatically detects encoding

Legacy: Draw text with Type0 font encoding (kept for compatibility)

Source

pub fn draw_text_unicode( &mut self, text: &str, x: f64, y: f64, ) -> Result<&mut Self>

👎Deprecated: Use draw_text() which automatically detects encoding

Legacy: Draw text with UTF-16BE encoding (kept for compatibility)

Trait Implementations§

Source§

impl Clone for GraphicsContext

Source§

fn clone(&self) -> GraphicsContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for GraphicsContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PatternGraphicsContext for GraphicsContext

Source§

fn set_fill_pattern(&mut self, pattern_name: &str) -> Result<()>

Set pattern as fill color
Source§

fn set_stroke_pattern(&mut self, pattern_name: &str) -> Result<()>

Set pattern as stroke color

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more