{"record":{"id":"a38ab7addd21eb53","repo":"flxzt/rnote","slug":"finishing-outputstream-failed-err-e","errorCode":null,"errorMessage":"Finishing outputstream failed, Err: {e:?}","messagePattern":"Finishing outputstream failed, Err: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/engine/export.rs","lineNumber":524,"sourceCode":"                        page_content.draw_to_cairo(\n                            &cairo_cx,\n                            doc_export_prefs.with_background,\n                            doc_export_prefs.with_pattern,\n                            doc_export_prefs.optimize_printing,\n                            DocExportPrefs::MARGIN,\n                            Engine::STROKE_EXPORT_IMAGE_SCALE,\n                        )?;\n                        cairo_cx.show_page().map_err(|e| {\n                            anyhow::anyhow!(\n                                \"Showing page failed while exporting page {i} as pdf, Err: {e:?}\"\n                            )\n                        })?;\n                        cairo_cx.restore()?;\n                    }\n                }\n                let data = *target_surface\n                    .finish_output_stream()\n                    .map_err(|e| anyhow::anyhow!(\"Finishing outputstream failed, Err: {e:?}\"))?\n                    .downcast::<Vec<u8>>()\n                    .map_err(|e| {\n                        anyhow::anyhow!(\"Downcasting finished output stream failed, Err: {e:?}\")\n                    })?;\n\n                Ok(data)\n            };\n\n            if oneshot_sender.send(result()).is_err() {\n                error!(\n                    \"Sending result to receiver failed while exporting document as Pdf bytes. Receiver already dropped.\"\n                );\n            }\n        });\n\n        oneshot_receiver\n    }\n","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/engine/export.rs#L506-L542","documentation":"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.","triggerScenarios":"Thrown at crates/rnote-engine/src/engine/export.rs:524 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the PDF export to rule out a transient surface-state failure.","Check the output writer/stream configuration passed to the PDF surface creation.","Verify the cairo surface/device type matches the expected PdfStream type."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}