2019-11-07 11:45:03 +02:00
|
|
|
use docx_core;
|
2019-09-11 21:28:14 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
|
#[derive(Debug)]
|
2019-11-07 11:45:03 +02:00
|
|
|
pub struct Docx(docx_core::Docx);
|
2019-09-11 21:28:14 +03:00
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2019-11-07 11:45:03 +02:00
|
|
|
#[allow(non_snake_case)]
|
|
|
|
|
pub fn createDocx() -> Docx {
|
|
|
|
|
Docx(docx_core::Docx::new())
|
2019-09-11 21:28:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2019-11-07 11:45:03 +02:00
|
|
|
impl Docx {
|
|
|
|
|
pub fn add_paragraph(mut self) -> Self {
|
|
|
|
|
self.0 = self
|
|
|
|
|
.0
|
|
|
|
|
.add_paragraph(docx_core::Paragraph::new().add_run(docx_core::Run::new("Hello")));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn build(&self) -> Vec<u8> {
|
|
|
|
|
let buf = Vec::new();
|
|
|
|
|
let mut cur = std::io::Cursor::new(buf);
|
|
|
|
|
let b = self.0.build();
|
|
|
|
|
docx_core::zip(&mut cur, b).unwrap();
|
|
|
|
|
cur.into_inner()
|
2019-09-11 21:28:14 +03:00
|
|
|
}
|
|
|
|
|
|
2019-11-07 11:45:03 +02:00
|
|
|
pub fn test(&self, t: docx_core::StyleType) {
|
|
|
|
|
()
|
2019-09-11 21:28:14 +03:00
|
|
|
}
|
|
|
|
|
}
|