Skip to main content

DOCX

Struct DOCX 

Source
pub struct DOCX {
    pub content: HashMap<String, String>,
    pub file_name: String,
    pub placeholders: HashMap<String, Value>,
    pub placeholders_blocks: HashMap<String, String>,
    pub placeholder_images: HashMap<String, String>,
}
Expand description

§DOCX struct

create template for docx file

file_name - docx file input name

content - content of word file

placeholder/placeholder_block/placeholder_images - saving your placeholders

Fields§

§content: HashMap<String, String>§file_name: String§placeholders: HashMap<String, Value>§placeholders_blocks: HashMap<String, String>§placeholder_images: HashMap<String, String>

Implementations§

Source§

impl DOCX

Source

pub fn new(file_name: String) -> DOCX

Create new docx manager

file_name input file name

Source

pub fn read(&mut self)

Read DOCX file

Source

pub fn add_placeholder<T>(&mut self, placeholder: &str, replaced_content: T)
where Value: From<T>,

Add placeholders to DOCX

placeholder - Placeholder

replaced_content - value for placeholder

Source

pub fn add_placeholders_from_json(&mut self, placeholders_content: &str)

Add placeholders from json

placeholders_content - json data

Source

pub fn add_image_placeholder(&mut self, placeholder: &str, image: &str)

Add image placeholder

placeholder id of image in docx image directory of image for replace

Source

pub fn remove_image_placeholder(&mut self, placeholder: &str)

Remove image placeholder

placeholder - placeholder tag

Source

pub fn init_placeholders(&mut self)

Init placeholders

Source

pub fn save(&self, output: &str)

save output file

output - output

Source

pub fn render(&self) -> Vec<u8>

Render docx file

You can use this in web

Auto Trait Implementations§

§

impl Freeze for DOCX

§

impl RefUnwindSafe for DOCX

§

impl Send for DOCX

§

impl Sync for DOCX

§

impl Unpin for DOCX

§

impl UnsafeUnpin for DOCX

§

impl UnwindSafe for DOCX

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