PdfDocument

Struct PdfDocument 

Source
pub struct PdfDocument {
    pub doc: *mut _HPDF_Doc_Rec,
}
Expand description

The PDF document.

Fields§

§doc: *mut _HPDF_Doc_Rec

The reference to the haru document.

Implementations§

Source§

impl PdfDocument

Source

pub fn new() -> Self

Create an instance of a document object and initialize it.

API: HPDF_New

Source

pub fn set_page_mode(&self, mode: PageMode) -> Result<&Self, HaruError>

set_page_mode() sets how the document should be displayed.

API: HPDF_SetPageMode

Source

pub fn get_page_mode(&self) -> PageMode

get_page_mode() returns the current setting for page mode.

API: HPDF_GetPageMode

Source

pub fn get_font( &self, fontname: &str, encoding_name: Option<&str>, ) -> Result<PdfFont, HaruError>

get_font() returns the font specified by fontname and encoding_name.

API: HPDF_GetFont

Source

pub fn set_page_layout(&self, layout: PageLayout) -> Result<&Self, HaruError>

set_page_layout() sets how the page should be displayed. If this attribute is not set, the setting of the viewer application is used.

API: HPDF_SetPageLayout

Source

pub fn get_page_layout(&self) -> PageLayout

get_page_layout() returns the current setting for page layout.

API: HPDF_GetPageLayout

Source

pub fn save_to_file(&self, filename: &str) -> Result<&Self, HaruError>

save_to_file() saves the PDF document to a file.

Source

pub fn get_error(&self) -> HaruError

Returns the last error code of specified document object.

API: HPDF_GetError

Source

pub fn add_page(&self) -> Result<PdfPage, HaruError>

Create a new page.

API: HPDF_AddPage

Source

pub fn insert_page(&self, page: PdfPage) -> Result<PdfPage, HaruError>

insert_page() creates a new page and inserts it just before the specified page.

API: HPDF_InsertPage

Source

pub fn set_title(&self, title: &str) -> Result<&Self, HaruError>

Set the title of the document.

Source

pub fn set_password( &self, owner_passwd: &str, user_passwd: &str, ) -> Result<&Self, HaruError>

HPDF_SetPassword() sets a password for the document. If the password is set, document contents are encrypted.

Source

pub fn set_compression_mode( &self, mode: CompressionMode, ) -> Result<&Self, HaruError>

HPDF_SetCompressionMode() set the mode of compression.

Source

pub fn set_font_and_size( &self, page: &PdfPage, font: &PdfFont, size: f32, ) -> Result<&Self, HaruError>

set_font_and_size() sets the current font and size.

API: HPDF_Page_SetFontAndSize

Source

pub fn load_tt_font_from_file( &self, filename: &str, embedding: bool, ) -> Result<String, HaruError>

load_tt_font_from_file() loads a TrueType font file and returns a font object.

API: HPDF_LoadTTFontFromFile

Source

pub fn load_tt_font_from_file2( &self, filename: &str, index: u32, embedding: bool, ) -> Result<PdfFont, HaruError>

load_tt_font_from_file2() loads a TrueType font file and returns a font object.

API: HPDF_LoadTTFontFromFile2

Source

pub fn load_type1_font_from_file( &self, afm_filename: &str, pfm_filename: &str, ) -> Result<PdfFont, HaruError>

HPDF_LoadType1FontFromFile() loads a Type1 font file and returns a font object.

API: HPDF_LoadType1FontFromFile

Source

pub fn use_cns_fonts(&self) -> Result<&Self, HaruError>

HPDF_UseCNSFonts() loads Chinese simplified fonts.

API: HPDF_UseCNSFonts

Source

pub fn use_cnt_fonts(&self) -> Result<&Self, HaruError>

HPDF_UseCNTFonts() loads Chinese traditional fonts.

API: HPDF_UseCNTFonts

Source

pub fn use_jp_fonts(&self) -> Result<&Self, HaruError>

HPDF_UseJPFonts() loads Japanese fonts.

API: HPDF_UseJPFonts

Source

pub fn use_utf_encodings(&self) -> Result<&Self, HaruError>

Enable the UTF-8 encoding.

API: HPDF_UseUTFEncodings

Source

pub fn set_current_encoder( &self, encoding_name: &str, ) -> Result<&Self, HaruError>

Set the current encoder.

API: HPDF_SetCurrentEncoder

Source

pub fn use_kr_fonts(&self) -> Result<&Self, HaruError>

HPDF_UseKRFonts() loads Korean fonts.

API: HPDF_UseKRFonts

Source

pub fn load_png_image_from_file( &self, filename: &str, ) -> Result<PdfImage, HaruError>

load_png_image_from_file() loads an external PNG image file.

API: HPDF_LoadPngImageFromFile

Source

pub fn load_png_image_from_file2( &self, filename: &str, ) -> Result<PdfImage, HaruError>

load_png_image_from_file2() loads an external PNG image file. Unlike load_png_image_from_file(), load_png_image_from_file2() does not load all the data immediately (only size and color properties are loaded). The main data are loaded just before the image object is written to PDF, and the loaded data are deleted immediately.

API: HPDF_LoadPngImageFromFile2

Source

pub fn load_jpeg_image_from_file( &self, filename: &str, ) -> Result<PdfImage, HaruError>

HPDF_LoadJpegImageFromFile() loads an external JPEG image file.

API: HPDF_LoadJpegImageFromFile

Trait Implementations§

Source§

impl Debug for PdfDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PdfDocument

Source§

fn default() -> Self

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

impl Drop for PdfDocument

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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, 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.