pub struct PdfDocument {
pub doc: *mut _HPDF_Doc_Rec,
}Expand description
The PDF document.
Fields§
§doc: *mut _HPDF_Doc_RecThe reference to the haru document.
Implementations§
Source§impl PdfDocument
impl PdfDocument
Sourcepub fn set_page_mode(&self, mode: PageMode) -> Result<&Self, HaruError>
pub fn set_page_mode(&self, mode: PageMode) -> Result<&Self, HaruError>
set_page_mode() sets how the document should be displayed.
API: HPDF_SetPageMode
Sourcepub fn get_page_mode(&self) -> PageMode
pub fn get_page_mode(&self) -> PageMode
get_page_mode() returns the current setting for page mode.
API: HPDF_GetPageMode
Sourcepub fn get_font(
&self,
fontname: &str,
encoding_name: Option<&str>,
) -> Result<PdfFont, HaruError>
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
Sourcepub fn set_page_layout(&self, layout: PageLayout) -> Result<&Self, HaruError>
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
Sourcepub fn get_page_layout(&self) -> PageLayout
pub fn get_page_layout(&self) -> PageLayout
get_page_layout() returns the current setting for page layout.
API: HPDF_GetPageLayout
Sourcepub fn save_to_file(&self, filename: &str) -> Result<&Self, HaruError>
pub fn save_to_file(&self, filename: &str) -> Result<&Self, HaruError>
save_to_file() saves the PDF document to a file.
Sourcepub fn get_error(&self) -> HaruError
pub fn get_error(&self) -> HaruError
Returns the last error code of specified document object.
API: HPDF_GetError
Sourcepub fn insert_page(&self, page: PdfPage) -> Result<PdfPage, HaruError>
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
Sourcepub fn set_title(&self, title: &str) -> Result<&Self, HaruError>
pub fn set_title(&self, title: &str) -> Result<&Self, HaruError>
Set the title of the document.
Sourcepub fn set_password(
&self,
owner_passwd: &str,
user_passwd: &str,
) -> Result<&Self, HaruError>
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.
Sourcepub fn set_compression_mode(
&self,
mode: CompressionMode,
) -> Result<&Self, HaruError>
pub fn set_compression_mode( &self, mode: CompressionMode, ) -> Result<&Self, HaruError>
HPDF_SetCompressionMode() set the mode of compression.
Sourcepub fn set_font_and_size(
&self,
page: &PdfPage,
font: &PdfFont,
size: f32,
) -> Result<&Self, HaruError>
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
Sourcepub fn load_tt_font_from_file(
&self,
filename: &str,
embedding: bool,
) -> Result<String, HaruError>
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
Sourcepub fn load_tt_font_from_file2(
&self,
filename: &str,
index: u32,
embedding: bool,
) -> Result<PdfFont, HaruError>
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
Sourcepub fn load_type1_font_from_file(
&self,
afm_filename: &str,
pfm_filename: &str,
) -> Result<PdfFont, HaruError>
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
Sourcepub fn use_cns_fonts(&self) -> Result<&Self, HaruError>
pub fn use_cns_fonts(&self) -> Result<&Self, HaruError>
HPDF_UseCNSFonts() loads Chinese simplified fonts.
API: HPDF_UseCNSFonts
Sourcepub fn use_cnt_fonts(&self) -> Result<&Self, HaruError>
pub fn use_cnt_fonts(&self) -> Result<&Self, HaruError>
HPDF_UseCNTFonts() loads Chinese traditional fonts.
API: HPDF_UseCNTFonts
Sourcepub fn use_jp_fonts(&self) -> Result<&Self, HaruError>
pub fn use_jp_fonts(&self) -> Result<&Self, HaruError>
HPDF_UseJPFonts() loads Japanese fonts.
API: HPDF_UseJPFonts
Sourcepub fn use_utf_encodings(&self) -> Result<&Self, HaruError>
pub fn use_utf_encodings(&self) -> Result<&Self, HaruError>
Enable the UTF-8 encoding.
API: HPDF_UseUTFEncodings
Sourcepub fn set_current_encoder(
&self,
encoding_name: &str,
) -> Result<&Self, HaruError>
pub fn set_current_encoder( &self, encoding_name: &str, ) -> Result<&Self, HaruError>
Set the current encoder.
API: HPDF_SetCurrentEncoder
Sourcepub fn use_kr_fonts(&self) -> Result<&Self, HaruError>
pub fn use_kr_fonts(&self) -> Result<&Self, HaruError>
HPDF_UseKRFonts() loads Korean fonts.
API: HPDF_UseKRFonts
Sourcepub fn load_png_image_from_file(
&self,
filename: &str,
) -> Result<PdfImage, HaruError>
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
Sourcepub fn load_png_image_from_file2(
&self,
filename: &str,
) -> Result<PdfImage, HaruError>
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