feat: add pack method
parent
69fc4e9048
commit
37d4a157d5
|
@ -1,5 +1,8 @@
|
|||
use super::XMLDocProps;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::zipper;
|
||||
use std::io::prelude::*;
|
||||
use std::io::Seek;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct XMLDocx {
|
||||
|
@ -9,3 +12,12 @@ pub struct XMLDocx {
|
|||
pub styles: Vec<u8>,
|
||||
pub document: Vec<u8>,
|
||||
}
|
||||
|
||||
impl XMLDocx {
|
||||
pub fn pack<W>(self, w: W) -> zip::result::ZipResult<()>
|
||||
where
|
||||
W: Write + Seek,
|
||||
{
|
||||
zipper::zip(w, self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ pub use types::*;
|
|||
pub use zipper::*;
|
||||
|
||||
pub fn simple() {
|
||||
let xml = Docx::new()
|
||||
.add_paragraph(Paragraph::new().add_run(Run::new("Hello")))
|
||||
.build();
|
||||
let path = std::path::Path::new("./test.docx");
|
||||
let file = std::fs::File::create(&path).unwrap();
|
||||
zip(file, xml);
|
||||
Docx::new()
|
||||
.add_paragraph(Paragraph::new().add_run(Run::new("Hello")))
|
||||
.build()
|
||||
.pack(file);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue