Skip to main content

write_docx

Function write_docx 

Source
pub fn write_docx(model: &DocModel) -> Vec<u8> 
Expand description

Serialize a DocModel — one you built from data, built with DocBuilder, or read from a .doc/.docx — to a clean, Office-openable .docx byte buffer. This is the authoring entry point: construct a model (paragraphs/runs with fonts, sizes, colors; headings; styled/sized/shaded tables; images; page setup) and write a styled Word document. Available with the default docx feature.

Image bytes are trusted as-is: an embedded Image’s bytes are written verbatim under a part typed from its mime — the writer does not transcode or validate the raster, so the caller must ensure bytes really are that format (a mismatch produces a part Word can’t render). The element-tree editor’s Document::add_image_png / Document::replace_image_png and JPEG/GIF/BMP/TIFF/WebP counterparts do validate, since they accept arbitrary caller input.