{"record":{"id":"03a1138a5c75d3fe","repo":"flxzt/rnote","slug":"showing-page-failed-while-exporting-page-i-as-pd","errorCode":null,"errorMessage":"Showing page failed while exporting page {i} as pdf, Err: {e:?}","messagePattern":"Showing page failed while exporting page (.+?) as pdf, Err: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/engine/export.rs","lineNumber":515,"sourceCode":"                    let cairo_cx = cairo::Context::new(&target_surface)\n                        .context(\"Creating new cairo context for pdf target surface failed.\")?;\n\n                    for (i, page_content) in pages_content.into_iter().enumerate() {\n                        let Some(page_bounds) = page_content.bounds() else {\n                            continue;\n                        };\n                        cairo_cx.save()?;\n                        cairo_cx.translate(-page_bounds.mins[0], -page_bounds.mins[1]);\n                        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() {","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/engine/export.rs#L497-L533","documentation":"Error wrapper around File::open in load_sound_from_path: opening `<resource_path>/<sound_name>.<ending>` failed (missing asset, wrong path, or permission error) while loading a bundled sound for the audio player. The path was checked with exists() just before, so the failure is typically permissions or a race.","triggerScenarios":"Thrown at crates/rnote-engine/src/engine/export.rs:515 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the error variant e: cairo Error::SurfaceFinished means the pdf target surface was finished before drawing — keep the surface alive and do not use the cairo context after finish_output_stream()/flush.","Retry the export once with a freshly created cairo surface and context; transient surface/IO failures typically resolve on a new target.","Verify the failing page's content: render pages one by one (or into an intermediate surface) to isolate a page whose draw_to_cairo fails, and check for degenerate page_bounds values (NaN/zero-size) from bounds().","If running headless/CI, confirm a usable cairo rendering backend and required fonts are installed; missing fontconfig can make show/draw calls fail.","Update/verify cairo and pango crate versions match the system cairo library; mismatched native libs cause drawing failures mid-export."],"exampleFix":null,"handlingStrategy":null,"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"}