flxzt/rnote · error
Generating doc svg failed, returned None.
Error message
Generating doc svg failed, returned None.
What it means
During doc export, gen_svg is asked to render the whole document as SVG; it may return None (no renderable content) rather than an error. export_doc_as_svg_bytes treats that None as a failure and throws this error, since a doc export must always produce SVG.
Solutions
- Check the document has at least one drawable stroke/content before exporting as SVG.
- Relax export filters (with_background, with_pattern, optimize_printing) that may suppress all output.
- Handle the export error and report 'nothing to export' to the user instead of crashing.
- Fall back to exporting a blank page if an empty SVG is acceptable.
Example fix
// before
let svg_bytes = engine.export_doc(export_prefs).await?;
// after
if engine.document.content_bounds().is_none() {
eprintln!("document is empty; nothing to export as SVG");
} else {
let svg_bytes = engine.export_doc(export_prefs).await?;
} Defensive patterns
Strategy: try-catch
Validate before calling
fn can_export_doc(engine: &RnoteEngine) -> bool {
engine.document.content_bounds().is_some()
} Try / catch
match engine.export_doc(export_prefs).await {
Ok(bytes) => bytes,
Err(e) if e.to_string().contains("returned None") => {
eprintln!("nothing to export: document produced no SVG");
Vec::new()
}
Err(e) => return Err(e),
} Prevention
- Check content_bounds/is-empty before doc export
- Avoid export filter combinations that can suppress all output
- Surface 'nothing to export' to users instead of a raw error
- Test export on empty and edge-case documents
When it happens
Trigger: Calling export_doc -> export_doc_as_svg_bytes on a document whose gen_svg returns None, e.g. a document with no renderable strokes/content or filter settings (with_background, optimize_printing) eliminating everything.
Common situations: Exporting an empty or effectively empty .rnote file, exporting after programmatic modifications that removed all content, or calling the export API from scripts on documents that were never populated.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- DocExportFormat try_from
- DocPagesExportFormat try_from
- SelectionExportFormat try_from
- Creating svg surface with dimensions
- The output file " " needs to have a supported extension to…
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/d2025b16b401c7a6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-engine/src/engine/export.rs:444
fn export_doc_as_svg_bytes(
&self,
doc_export_prefs_override: Option<DocExportPrefs>,
) -> oneshot::Receiver<Result<Vec<u8>, anyhow::Error>> {
let (oneshot_sender, oneshot_receiver) = oneshot::channel::<anyhow::Result<Vec<u8>>>();
let doc_export_prefs =
doc_export_prefs_override.unwrap_or(self.config.read().export_prefs.doc_export_prefs);
let doc_content = self.extract_document_content();
rayon::spawn(move || {
let result = || -> anyhow::Result<Vec<u8>> {
let doc_svg = doc_content
.gen_svg(
doc_export_prefs.with_background,
doc_export_prefs.with_pattern,
doc_export_prefs.optimize_printing,
DocExportPrefs::MARGIN,
)?
.ok_or(anyhow::anyhow!("Generating doc svg failed, returned None."))?;
Ok(rnote_compose::utils::add_xml_header(
rnote_compose::utils::wrap_svg_root(
doc_svg.svg_data.as_str(),
Some(doc_svg.bounds),
Some(doc_svg.bounds),
false,
)
.as_str(),
)
.into_bytes())
};
if oneshot_sender.send(result()).is_err() {
error!(
"Sending result to receiver failed while exporting document as Svg bytes. Receiver already dropped."
);
}
});View on GitHub (pinned to bbc5354502)