Define header footer (#678)
* chore: define header and footer json properties * fix: some errorsmain
parent
5799884862
commit
179e69959b
|
@ -34,7 +34,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn hello() -> Result<(), DocxError> {
|
pub fn hello() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./hello.docx");
|
let path = std::path::Path::new("./hello.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./alignment.docx");
|
let path = std::path::Path::new("./alignment.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/bookmark.docx");
|
let path = std::path::Path::new("./output/bookmark.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_bookmark_start(1, "hello")
|
.add_bookmark_start(1, "hello")
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/comment.docx");
|
let path = std::path::Path::new("./output/comment.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/custom_property.docx");
|
let path = std::path::Path::new("./output/custom_property.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.custom_property("hello", "world")
|
.custom_property("hello", "world")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/custom_xml.docx");
|
let path = std::path::Path::new("./output/custom_xml.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.add_custom_item("06AC5857-5C65-A94A-BCEC-37356A209BC3", "<root xmlns=\"https://exampple.com\"><item name=\"Cheap Item\" price=\"$193.95\"/><item name=\"Expensive Item\" price=\"$931.88\"/></root>")
|
.add_custom_item("06AC5857-5C65-A94A-BCEC-37356A209BC3", "<root xmlns=\"https://exampple.com\"><item name=\"Cheap Item\" price=\"$193.95\"/><item name=\"Expensive Item\" price=\"$931.88\"/></root>")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/data_binding.docx");
|
let path = std::path::Path::new("./output/data_binding.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/dirty_toc.docx");
|
let path = std::path::Path::new("./output/dirty_toc.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("Hello"))
|
.add_run(Run::new().add_text("Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/doc_id.docx");
|
let path = std::path::Path::new("./output/doc_id.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("World")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("World")))
|
||||||
.doc_id("2F0CF1F9-607F-5941-BF59-8A81BE87AAAA")
|
.doc_id("2F0CF1F9-607F-5941-BF59-8A81BE87AAAA")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/even_header.docx");
|
let path = std::path::Path::new("./output/even_header.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let header =
|
let header =
|
||||||
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
||||||
let even_header =
|
let even_header =
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/first_header.docx");
|
let path = std::path::Path::new("./output/first_header.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let header =
|
let header =
|
||||||
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
||||||
let first_header =
|
let first_header =
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./font.docx");
|
let path = std::path::Path::new("./font.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new().add_run(
|
Paragraph::new().add_run(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/font_size.docx");
|
let path = std::path::Path::new("./output/font_size.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").size(24)))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").size(24)))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/footer.docx");
|
let path = std::path::Path::new("./output/footer.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let footer =
|
let footer =
|
||||||
Footer::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
Footer::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
||||||
Docx::new()
|
Docx::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/header.docx");
|
let path = std::path::Path::new("./output/header.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let header =
|
let header =
|
||||||
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")));
|
||||||
Docx::new()
|
Docx::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/hello.docx");
|
let path = std::path::Path::new("./output/examples/hello.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./history.docx");
|
let path = std::path::Path::new("./history.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/hyperlink.docx");
|
let path = std::path::Path::new("./output/hyperlink.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_hyperlink(
|
.add_paragraph(Paragraph::new().add_hyperlink(
|
||||||
Hyperlink::new("anchor", HyperlinkType::Anchor).add_run(Run::new().add_text("Hello")),
|
Hyperlink::new("anchor", HyperlinkType::Anchor).add_run(Run::new().add_text("Hello")),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/image_floating.docx");
|
let path = std::path::Path::new("./output/examples/image_floating.docx");
|
||||||
let file = File::create(&path).unwrap();
|
let file = File::create(path).unwrap();
|
||||||
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = img.read_to_end(&mut buf).unwrap();
|
let _ = img.read_to_end(&mut buf).unwrap();
|
||||||
|
|
|
@ -5,7 +5,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/image_inline.docx");
|
let path = std::path::Path::new("./output/examples/image_inline.docx");
|
||||||
let file = File::create(&path).unwrap();
|
let file = File::create(path).unwrap();
|
||||||
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = img.read_to_end(&mut buf).unwrap();
|
let _ = img.read_to_end(&mut buf).unwrap();
|
||||||
|
|
|
@ -5,7 +5,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/image_inline_rotate.docx");
|
let path = std::path::Path::new("./output/examples/image_inline_rotate.docx");
|
||||||
let file = File::create(&path).unwrap();
|
let file = File::create(path).unwrap();
|
||||||
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
let mut img = File::open("./images/cat_min.jpg").unwrap();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = img.read_to_end(&mut buf).unwrap();
|
let _ = img.read_to_end(&mut buf).unwrap();
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub const DUMMY: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/indent.docx");
|
let path = std::path::Path::new("./output/indent.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
|
||||||
Some(840),
|
Some(840),
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/nested_comment.docx");
|
let path = std::path::Path::new("./output/nested_comment.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./numbering.docx");
|
let path = std::path::Path::new("./numbering.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
fn main() -> Result<(), DocxError> {
|
fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./outlineLvl.docx");
|
let path = std::path::Path::new("./outlineLvl.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/page_margin.docx");
|
let path = std::path::Path::new("./output/page_margin.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/page_size.docx");
|
let path = std::path::Path::new("./output/page_size.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.page_size(200, 400)
|
.page_size(200, 400)
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/sdt.docx");
|
let path = std::path::Path::new("./output/sdt.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p = Paragraph::new().add_run(
|
let p = Paragraph::new().add_run(
|
||||||
Run::new()
|
Run::new()
|
||||||
.add_text("Hello")
|
.add_text("Hello")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/style.docx");
|
let path = std::path::Path::new("./output/examples/style.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("Hello").style("Run1"))
|
.add_run(Run::new().add_text("Hello").style("Run1"))
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./table.docx");
|
let path = std::path::Path::new("./table.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let table = Table::new(vec![TableRow::new(vec![
|
let table = Table::new(vec![TableRow::new(vec![
|
||||||
TableCell::new().add_paragraph(Paragraph::new())
|
TableCell::new().add_paragraph(Paragraph::new())
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./table_border.docx");
|
let path = std::path::Path::new("./table_border.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let table = Table::new(vec![
|
let table = Table::new(vec![
|
||||||
TableRow::new(vec![
|
TableRow::new(vec![
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/toc_simple.docx");
|
let path = std::path::Path::new("./output/toc_simple.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("!!Hello"))
|
.add_run(Run::new().add_text("!!Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/toc_with_comment.docx");
|
let path = std::path::Path::new("./output/examples/toc_with_comment.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("!!Hello"))
|
.add_run(Run::new().add_text("!!Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/toc_with_hyperlink.docx");
|
let path = std::path::Path::new("./output/toc_with_hyperlink.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("Hello"))
|
.add_run(Run::new().add_text("Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/toc_with_item.docx");
|
let path = std::path::Path::new("./output/toc_with_item.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("Hello"))
|
.add_run(Run::new().add_text("Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/examples/toc_with_style_level.docx");
|
let path = std::path::Path::new("./output/examples/toc_with_style_level.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let style1 = Style::new("Heading1", StyleType::Paragraph).name("Heading 1");
|
let style1 = Style::new("Heading1", StyleType::Paragraph).name("Heading 1");
|
||||||
let style2 = Style::new("StyleLevel1", StyleType::Paragraph)
|
let style2 = Style::new("StyleLevel1", StyleType::Paragraph)
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/toc_with_tc.docx");
|
let path = std::path::Path::new("./output/toc_with_tc.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let p1 = Paragraph::new()
|
let p1 = Paragraph::new()
|
||||||
.add_run(Run::new().add_text("Hello"))
|
.add_run(Run::new().add_text("Hello"))
|
||||||
.style("Heading1")
|
.style("Heading1")
|
||||||
|
|
|
@ -2,7 +2,7 @@ use docx_rs::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), DocxError> {
|
pub fn main() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./output/web_ext.docx");
|
let path = std::path::Path::new("./output/web_ext.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.taskpanes()
|
.taskpanes()
|
||||||
.web_extension(
|
.web_extension(
|
||||||
|
|
|
@ -13,9 +13,9 @@ pub enum DeleteInstrText {
|
||||||
Unsupported(String),
|
Unsupported(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildXML for Box<DeleteInstrText> {
|
impl BuildXML for DeleteInstrText {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
let instr = match self.as_ref() {
|
let instr = match self {
|
||||||
DeleteInstrText::TOC(toc) => toc.build(),
|
DeleteInstrText::TOC(toc) => toc.build(),
|
||||||
DeleteInstrText::TC(tc) => tc.build(),
|
DeleteInstrText::TC(tc) => tc.build(),
|
||||||
DeleteInstrText::PAGEREF(page_ref) => page_ref.build(),
|
DeleteInstrText::PAGEREF(page_ref) => page_ref.build(),
|
||||||
|
@ -30,6 +30,12 @@ impl BuildXML for Box<DeleteInstrText> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BuildXML for Box<DeleteInstrText> {
|
||||||
|
fn build(&self) -> Vec<u8> {
|
||||||
|
self.as_ref().build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Serialize for DeleteInstrText {
|
impl Serialize for DeleteInstrText {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -80,10 +86,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_toc_instr() {
|
fn test_delete_toc_instr() {
|
||||||
let b = Box::new(DeleteInstrText::TOC(
|
let b = DeleteInstrText::TOC(InstrToC::new().heading_styles_range(1, 3)).build();
|
||||||
InstrToC::new().heading_styles_range(1, 3),
|
|
||||||
))
|
|
||||||
.build();
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str::from_utf8(&b).unwrap(),
|
str::from_utf8(&b).unwrap(),
|
||||||
r#"<w:delInstrText>TOC \o "1-3"</w:delInstrText>"#
|
r#"<w:delInstrText>TOC \o "1-3"</w:delInstrText>"#
|
||||||
|
|
|
@ -56,6 +56,12 @@ impl Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildXML for Box<Drawing> {
|
impl BuildXML for Box<Drawing> {
|
||||||
|
fn build(&self) -> Vec<u8> {
|
||||||
|
self.as_ref().build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BuildXML for Drawing {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
let b = XMLBuilder::new();
|
let b = XMLBuilder::new();
|
||||||
let mut b = b.open_drawing();
|
let mut b = b.open_drawing();
|
||||||
|
@ -161,7 +167,7 @@ mod tests {
|
||||||
let mut img = std::fs::File::open("../images/cat_min.jpg").unwrap();
|
let mut img = std::fs::File::open("../images/cat_min.jpg").unwrap();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = img.read_to_end(&mut buf).unwrap();
|
let _ = img.read_to_end(&mut buf).unwrap();
|
||||||
let d = Box::new(Drawing::new().pic(Pic::new(&buf))).build();
|
let d = Drawing::new().pic(Pic::new(&buf)).build();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str::from_utf8(&d).unwrap(),
|
str::from_utf8(&d).unwrap(),
|
||||||
r#"<w:drawing>
|
r#"<w:drawing>
|
||||||
|
@ -210,7 +216,7 @@ mod tests {
|
||||||
let mut img = std::fs::File::open("../images/cat_min.jpg").unwrap();
|
let mut img = std::fs::File::open("../images/cat_min.jpg").unwrap();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = img.read_to_end(&mut buf).unwrap();
|
let _ = img.read_to_end(&mut buf).unwrap();
|
||||||
let d = Box::new(Drawing::new().pic(Pic::new(&buf).overlapping())).build();
|
let d = Drawing::new().pic(Pic::new(&buf).overlapping()).build();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str::from_utf8(&d).unwrap(),
|
str::from_utf8(&d).unwrap(),
|
||||||
r#"<w:drawing>
|
r#"<w:drawing>
|
||||||
|
@ -264,7 +270,7 @@ mod tests {
|
||||||
pic = pic.relative_from_h(RelativeFromHType::Column);
|
pic = pic.relative_from_h(RelativeFromHType::Column);
|
||||||
pic = pic.relative_from_v(RelativeFromVType::Paragraph);
|
pic = pic.relative_from_v(RelativeFromVType::Paragraph);
|
||||||
pic = pic.position_h(DrawingPosition::Align(PicAlign::Right));
|
pic = pic.position_h(DrawingPosition::Align(PicAlign::Right));
|
||||||
let d = Box::new(Drawing::new().pic(pic)).build();
|
let d = Drawing::new().pic(pic).build();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
str::from_utf8(&d).unwrap(),
|
str::from_utf8(&d).unwrap(),
|
||||||
r#"<w:drawing>
|
r#"<w:drawing>
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub const DUMMY: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||||
#[test]
|
#[test]
|
||||||
pub fn hello() -> Result<(), DocxError> {
|
pub fn hello() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/hello.docx");
|
let path = std::path::Path::new("./tests/output/hello.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.build()
|
.build()
|
||||||
|
@ -20,7 +20,7 @@ pub fn hello() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn indent() -> Result<(), DocxError> {
|
pub fn indent() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/indent.docx");
|
let path = std::path::Path::new("./tests/output/indent.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
|
||||||
Some(840),
|
Some(840),
|
||||||
|
@ -50,7 +50,7 @@ pub fn indent() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn size() -> Result<(), DocxError> {
|
pub fn size() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/size.docx");
|
let path = std::path::Path::new("./tests/output/size.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").size(60)))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").size(60)))
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
|
@ -66,7 +66,7 @@ pub fn size() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn alignment() -> Result<(), DocxError> {
|
pub fn alignment() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/alignment.docx");
|
let path = std::path::Path::new("./tests/output/alignment.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
|
@ -82,7 +82,7 @@ pub fn alignment() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn table() -> Result<(), DocxError> {
|
pub fn table() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/table.docx");
|
let path = std::path::Path::new("./tests/output/table.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let table = Table::new(vec![
|
let table = Table::new(vec![
|
||||||
TableRow::new(vec![
|
TableRow::new(vec![
|
||||||
|
@ -101,7 +101,7 @@ pub fn table() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn table_with_grid() -> Result<(), DocxError> {
|
pub fn table_with_grid() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/table_with_grid.docx");
|
let path = std::path::Path::new("./tests/output/table_with_grid.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let table = Table::new(vec![
|
let table = Table::new(vec![
|
||||||
TableRow::new(vec![
|
TableRow::new(vec![
|
||||||
|
@ -121,7 +121,7 @@ pub fn table_with_grid() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn table_merged() -> Result<(), DocxError> {
|
pub fn table_merged() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/table_merged.docx");
|
let path = std::path::Path::new("./tests/output/table_merged.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
let table = Table::new(vec![
|
let table = Table::new(vec![
|
||||||
TableRow::new(vec![
|
TableRow::new(vec![
|
||||||
|
@ -159,7 +159,7 @@ pub fn table_merged() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn decoration() -> Result<(), DocxError> {
|
pub fn decoration() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/decoration.docx");
|
let path = std::path::Path::new("./tests/output/decoration.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -189,7 +189,7 @@ pub fn decoration() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn tab_and_break() -> Result<(), DocxError> {
|
pub fn tab_and_break() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/tab_and_break.docx");
|
let path = std::path::Path::new("./tests/output/tab_and_break.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new().add_run(
|
Paragraph::new().add_run(
|
||||||
|
@ -209,7 +209,7 @@ pub fn tab_and_break() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn history() -> Result<(), DocxError> {
|
pub fn history() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/history.docx");
|
let path = std::path::Path::new("./tests/output/history.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -228,7 +228,7 @@ pub fn history() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn underline() -> Result<(), DocxError> {
|
pub fn underline() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/underline.docx");
|
let path = std::path::Path::new("./tests/output/underline.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").underline("single")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello").underline("single")))
|
||||||
.build()
|
.build()
|
||||||
|
@ -239,7 +239,7 @@ pub fn underline() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn highlight() -> Result<(), DocxError> {
|
pub fn highlight() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/highlight.docx");
|
let path = std::path::Path::new("./tests/output/highlight.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -254,7 +254,7 @@ pub fn highlight() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn comments() -> Result<(), DocxError> {
|
pub fn comments() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/comments.docx");
|
let path = std::path::Path::new("./tests/output/comments.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -276,7 +276,7 @@ pub fn comments() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn comments_to_table() -> Result<(), DocxError> {
|
pub fn comments_to_table() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/comments_table.docx");
|
let path = std::path::Path::new("./tests/output/comments_table.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
let table = Table::new(vec![TableRow::new(vec![
|
let table = Table::new(vec![TableRow::new(vec![
|
||||||
TableCell::new().add_paragraph(
|
TableCell::new().add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -312,7 +312,7 @@ pub fn comments_to_table() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn default_numbering() -> Result<(), DocxError> {
|
pub fn default_numbering() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/default_numbering.docx");
|
let path = std::path::Path::new("./tests/output/default_numbering.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -342,7 +342,7 @@ pub fn default_numbering() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn user_numbering() -> Result<(), DocxError> {
|
pub fn user_numbering() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/user_numbering.docx");
|
let path = std::path::Path::new("./tests/output/user_numbering.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -375,7 +375,7 @@ pub fn user_numbering() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn escape() -> Result<(), DocxError> {
|
pub fn escape() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/escape.docx");
|
let path = std::path::Path::new("./tests/output/escape.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -390,7 +390,7 @@ pub fn escape() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn vanish() -> Result<(), DocxError> {
|
pub fn vanish() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/vanish.docx");
|
let path = std::path::Path::new("./tests/output/vanish.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
Paragraph::new()
|
Paragraph::new()
|
||||||
|
@ -406,7 +406,7 @@ pub fn vanish() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn date() -> Result<(), DocxError> {
|
pub fn date() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/date.docx");
|
let path = std::path::Path::new("./tests/output/date.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||||
.created_at("2019-01-01T00:00:00Z")
|
.created_at("2019-01-01T00:00:00Z")
|
||||||
|
@ -419,7 +419,7 @@ pub fn date() -> Result<(), DocxError> {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn line_spacing() -> Result<(), DocxError> {
|
pub fn line_spacing() -> Result<(), DocxError> {
|
||||||
let path = std::path::Path::new("./tests/output/line_spacing.docx");
|
let path = std::path::Path::new("./tests/output/line_spacing.docx");
|
||||||
let file = std::fs::File::create(&path).unwrap();
|
let file = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
Docx::new()
|
Docx::new()
|
||||||
.add_paragraph(
|
.add_paragraph(
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub fn read_hello() {
|
||||||
assert_json_snapshot!("read_hello", &json);
|
assert_json_snapshot!("read_hello", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/hello.json");
|
let path = std::path::Path::new("./tests/output/hello.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ pub fn read_numbering() {
|
||||||
assert_json_snapshot!("read_numbering", &json);
|
assert_json_snapshot!("read_numbering", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/numbering.json");
|
let path = std::path::Path::new("./tests/output/numbering.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ pub fn read_decoration() {
|
||||||
assert_json_snapshot!("read_decoration", &json);
|
assert_json_snapshot!("read_decoration", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/decoration.json");
|
let path = std::path::Path::new("./tests/output/decoration.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ pub fn read_highlight_and_underline() {
|
||||||
assert_json_snapshot!("read_highlight_and_underline", &json);
|
assert_json_snapshot!("read_highlight_and_underline", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/highlight_and_underline.json");
|
let path = std::path::Path::new("./tests/output/highlight_and_underline.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ pub fn read_history() {
|
||||||
assert_json_snapshot!("read_history", &json);
|
assert_json_snapshot!("read_history", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/history.json");
|
let path = std::path::Path::new("./tests/output/history.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ pub fn read_indent_word_online() {
|
||||||
assert_json_snapshot!("read_indent_word_online", &json);
|
assert_json_snapshot!("read_indent_word_online", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/indent_word_online.json");
|
let path = std::path::Path::new("./tests/output/indent_word_online.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ pub fn read_tab_and_break() {
|
||||||
assert_json_snapshot!("read_tab_and_break", &json);
|
assert_json_snapshot!("read_tab_and_break", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/tab_and_break.json");
|
let path = std::path::Path::new("./tests/output/tab_and_break.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ pub fn read_table_docx() {
|
||||||
assert_json_snapshot!("read_table_docx", &json);
|
assert_json_snapshot!("read_table_docx", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/table_docx.json");
|
let path = std::path::Path::new("./tests/output/table_docx.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ pub fn read_table_merged_libre_office() {
|
||||||
assert_json_snapshot!("read_table_merged_libre_office", &json);
|
assert_json_snapshot!("read_table_merged_libre_office", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/table_merged_libre_office.json");
|
let path = std::path::Path::new("./tests/output/table_merged_libre_office.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ pub fn read_bom() {
|
||||||
assert_json_snapshot!("read_bom", &json);
|
assert_json_snapshot!("read_bom", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/bom.json");
|
let path = std::path::Path::new("./tests/output/bom.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ pub fn read_bookmark() {
|
||||||
assert_json_snapshot!("read_bookmark", &json);
|
assert_json_snapshot!("read_bookmark", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/bookmark.json");
|
let path = std::path::Path::new("./tests/output/bookmark.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ pub fn read_insert_table() {
|
||||||
assert_json_snapshot!("read_insert_table", &json);
|
assert_json_snapshot!("read_insert_table", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/insert_table.json");
|
let path = std::path::Path::new("./tests/output/insert_table.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ pub fn read_textbox() {
|
||||||
assert_json_snapshot!("read_textbox", &json);
|
assert_json_snapshot!("read_textbox", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/textbox.json");
|
let path = std::path::Path::new("./tests/output/textbox.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ pub fn read_from_doc() {
|
||||||
assert_json_snapshot!("read_from_doc", &json);
|
assert_json_snapshot!("read_from_doc", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/from_doc.json");
|
let path = std::path::Path::new("./tests/output/from_doc.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ pub fn read_lvl_override() {
|
||||||
assert_json_snapshot!("read_lvl_override", &json);
|
assert_json_snapshot!("read_lvl_override", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/lvl_override.json");
|
let path = std::path::Path::new("./tests/output/lvl_override.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ pub fn read_comment() {
|
||||||
assert_json_snapshot!("read_comment", &json);
|
assert_json_snapshot!("read_comment", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/comment.json");
|
let path = std::path::Path::new("./tests/output/comment.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ pub fn read_extended_comment() {
|
||||||
assert_json_snapshot!("read_extended_comments", &json);
|
assert_json_snapshot!("read_extended_comments", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/extended_comments.json");
|
let path = std::path::Path::new("./tests/output/extended_comments.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ pub fn read_line_spacing() {
|
||||||
assert_json_snapshot!("line_spacing", &json);
|
assert_json_snapshot!("line_spacing", &json);
|
||||||
|
|
||||||
let path = std::path::Path::new("./tests/output/line_spacing.json");
|
let path = std::path::Path::new("./tests/output/line_spacing.json");
|
||||||
let mut file = std::fs::File::create(&path).unwrap();
|
let mut file = std::fs::File::create(path).unwrap();
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { ParagraphJSON } from "./paragraph";
|
||||||
|
import { TableJSON } from "./table";
|
||||||
|
|
||||||
|
export type FooterJSON = {
|
||||||
|
children: (ParagraphJSON | TableJSON)[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FooterReferenceJSON = {
|
||||||
|
footerType: string;
|
||||||
|
id: string;
|
||||||
|
};
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { ParagraphJSON } from "./paragraph";
|
||||||
|
import { TableJSON } from "./table";
|
||||||
|
|
||||||
|
export type HeaderJSON = {
|
||||||
|
children: (ParagraphJSON | TableJSON)[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type HeaderReferenceJSON = {
|
||||||
|
headerType: string;
|
||||||
|
id: string;
|
||||||
|
};
|
|
@ -59,6 +59,7 @@ export type SettingsJSON = {
|
||||||
defaultTabStop: number;
|
defaultTabStop: number;
|
||||||
adjustLineHeightInTable: boolean;
|
adjustLineHeightInTable: boolean;
|
||||||
characterSpacingControl?: CharacterSpacingValues | null;
|
characterSpacingControl?: CharacterSpacingValues | null;
|
||||||
|
evenAndOddHeaders: boolean;
|
||||||
zoom: number;
|
zoom: number;
|
||||||
docVars: { name: string; val: string }[];
|
docVars: { name: string; val: string }[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import { HeaderJSON, HeaderReferenceJSON } from "./header";
|
||||||
|
import { FooterJSON, FooterReferenceJSON } from "./footer";
|
||||||
|
|
||||||
export type DocGridType = "default" | "lines" | "linesAndChars" | "snapToChars";
|
export type DocGridType = "default" | "lines" | "linesAndChars" | "snapToChars";
|
||||||
|
|
||||||
export type SectionType =
|
export type SectionType =
|
||||||
|
@ -30,4 +33,19 @@ export type SectionPropertyJSON = {
|
||||||
columns: number;
|
columns: number;
|
||||||
docGrid?: DocGridJSON;
|
docGrid?: DocGridJSON;
|
||||||
sectionType?: SectionType;
|
sectionType?: SectionType;
|
||||||
|
titlePg?: boolean;
|
||||||
|
// header
|
||||||
|
headerReference?: HeaderReferenceJSON;
|
||||||
|
header?: HeaderJSON;
|
||||||
|
firstHeaderReference?: HeaderReferenceJSON;
|
||||||
|
firstHeader?: HeaderJSON;
|
||||||
|
eventHeaderReference?: HeaderReferenceJSON;
|
||||||
|
eventHeader?: HeaderJSON;
|
||||||
|
// footer
|
||||||
|
footerReference?: FooterReferenceJSON;
|
||||||
|
footer?: FooterJSON;
|
||||||
|
firstFooterReference?: FooterReferenceJSON;
|
||||||
|
firstFooter?: FooterJSON;
|
||||||
|
eventFooterReference?: FooterReferenceJSON;
|
||||||
|
eventFooter?: FooterJSON;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue