pub struct ImageXObject {
pub width: u32,
pub height: u32,
pub color_space: String,
pub bits_per_component: u8,
pub filter: String,
pub data: Vec<u8>,
}Expand description
PDF Image XObject representation
Fields§
§width: u32Image width in pixels
height: u32Image height in pixels
color_space: StringColor space (DeviceRGB, DeviceGray, etc.)
bits_per_component: u8Bits per component (typically 8)
filter: StringFilter name (DCTDecode for JPEG, FlateDecode for PNG)
data: Vec<u8>Raw image data (JPEG data for DCTDecode, compressed for FlateDecode)
Implementations§
Source§impl ImageXObject
impl ImageXObject
Sourcepub fn from_image_info(info: &ImageInfo) -> Result<Self>
pub fn from_image_info(info: &ImageInfo) -> Result<Self>
Create an XObject from ImageInfo
Sourcepub fn from_jpeg(jpeg_data: &[u8]) -> Result<Self>
pub fn from_jpeg(jpeg_data: &[u8]) -> Result<Self>
Create an XObject from JPEG data
JPEG images can be embedded directly in PDF using the DCTDecode filter, which allows the raw JPEG data to be used without decompression.
Sourcepub fn from_png(png_data: &[u8]) -> Result<Self>
pub fn from_png(png_data: &[u8]) -> Result<Self>
Create an XObject from PNG data
PNG images require decompression and recompression with FlateDecode.
Sourcepub fn to_pdf_stream(&self, object_id: u32) -> String
pub fn to_pdf_stream(&self, object_id: u32) -> String
Generate the PDF XObject dictionary and stream
Sourcepub fn stream_data(&self) -> &[u8] ⓘ
pub fn stream_data(&self) -> &[u8] ⓘ
Get the stream data
Sourcepub fn stream_end() -> &'static str
pub fn stream_end() -> &'static str
Get the stream end marker
Trait Implementations§
Source§impl Clone for ImageXObject
impl Clone for ImageXObject
Source§fn clone(&self) -> ImageXObject
fn clone(&self) -> ImageXObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ImageXObject
impl RefUnwindSafe for ImageXObject
impl Send for ImageXObject
impl Sync for ImageXObject
impl Unpin for ImageXObject
impl UnsafeUnpin for ImageXObject
impl UnwindSafe for ImageXObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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