flxzt/rnote · error

Finishing outputstream failed, Err

Error message

Finishing outputstream failed, Err: {e:?}

What it means

Wrapper in export_doc_as_pdf_bytes: downcasting the finished cairo stream/surface to the concrete PDF output object failed after all pages were shown, so the finished PDF bytes cannot be extracted. Raised once at the end of PDF generation when the cairo surface type doesn't match the expected stream target.

Solutions

  1. Re-run the PDF export to rule out a transient surface-state failure.
  2. Check the output writer/stream configuration passed to the PDF surface creation.
  3. Verify the cairo surface/device type matches the expected PdfStream type.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/rnote-engine/src/engine/export.rs:524 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/a38ab7addd21eb53. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-engine/src/engine/export.rs:524

                        page_content.draw_to_cairo(
                            &cairo_cx,
                            doc_export_prefs.with_background,
                            doc_export_prefs.with_pattern,
                            doc_export_prefs.optimize_printing,
                            DocExportPrefs::MARGIN,
                            Engine::STROKE_EXPORT_IMAGE_SCALE,
                        )?;
                        cairo_cx.show_page().map_err(|e| {
                            anyhow::anyhow!(
                                "Showing page failed while exporting page {i} as pdf, Err: {e:?}"
                            )
                        })?;
                        cairo_cx.restore()?;
                    }
                }
                let data = *target_surface
                    .finish_output_stream()
                    .map_err(|e| anyhow::anyhow!("Finishing outputstream failed, Err: {e:?}"))?
                    .downcast::<Vec<u8>>()
                    .map_err(|e| {
                        anyhow::anyhow!("Downcasting finished output stream failed, Err: {e:?}")
                    })?;

                Ok(data)
            };

            if oneshot_sender.send(result()).is_err() {
                error!(
                    "Sending result to receiver failed while exporting document as Pdf bytes. Receiver already dropped."
                );
            }
        });

        oneshot_receiver
    }

View on GitHub (pinned to bbc5354502)