diff --git a/src/app/update.rs b/src/app/update.rs index e62c65a3e..f94fd0b3c 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -976,8 +976,7 @@ impl OpenCADStudio { } #[cfg(target_arch = "wasm32")] { - let _ = version; - match crate::io::save_to_bytes(&self.tabs[i].scene.document, ext) { + match crate::io::save_to_bytes(&self.tabs[i].scene.document, ext, version) { Ok(bytes) => { crate::sys::download_bytes(&filename, &bytes); self.tabs[i].dirty = false; diff --git a/src/io/mod.rs b/src/io/mod.rs index f5067da2f..6226e58aa 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -357,10 +357,17 @@ pub fn save(doc: &CadDocument, path: &Path) -> Result<(), String> { } /// Serialize a document to an in-memory byte buffer, format chosen by `ext` -/// (`dxf` → DXF, anything else → DWG). Used by the web build, which hands the -/// bytes to a browser download instead of writing a path. -pub fn save_to_bytes(doc: &CadDocument, ext: &str) -> Result, String> { +/// (`dxf` → DXF, anything else → DWG) at the given DXF version (overriding +/// `doc.version`). Used by the web build, which hands the bytes to a browser +/// download instead of writing a path — the byte-buffer counterpart to +/// [`save_as_version`]. +pub fn save_to_bytes( + doc: &CadDocument, + ext: &str, + version: acadrust::DxfVersion, +) -> Result, String> { let mut doc = doc.clone(); + doc.version = version; sync_current_styles_on_save(&mut doc); match ext.to_lowercase().as_str() { "dxf" => DxfWriter::new(&doc).write_to_vec().map_err(|e| e.to_string()),