{"record":{"id":"08386cd64743a1ea","repo":"tonhowtf/omniget","slug":"conte-do","errorCode":null,"errorMessage":"conteúdo: {}","messagePattern":"conteúdo: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_form.rs","lineNumber":729,"sourceCode":"    font_size: f32,\n) -> anyhow::Result<()> {\n    let ids: Vec<(u32, ObjectId)> = doc.get_pages().into_iter().collect();\n    let font_id = doc.add_object(dictionary! {\n        \"Type\" => \"Font\",\n        \"Subtype\" => \"Type1\",\n        \"BaseFont\" => \"Helvetica\",\n        \"Encoding\" => \"WinAnsiEncoding\",\n    });\n    for (no, page_id) in &ids {\n        let ops: Vec<Operation> = stamps\n            .iter()\n            .filter(|(p, ..)| *p == *no as usize)\n            .flat_map(|(_, rect, text, multi)| draw_ops(text, *rect, font_size, *multi))\n            .collect();\n        if !ops.is_empty() {\n            let data = Content { operations: ops }\n                .encode()\n                .map_err(|e| anyhow!(\"conteúdo: {}\", e))?;\n            let stream_id = doc.add_object(Stream::new(dictionary! {}, data));\n            if let Some(res_id) = resource_dict_id(doc, *page_id) {\n                if let Ok(res) = doc.get_dictionary_mut(res_id) {\n                    let mut fonts = res\n                        .get(b\"Font\")\n                        .and_then(Object::as_dict)\n                        .cloned()\n                        .unwrap_or_default();\n                    fonts.set(\"OGFFfont\", Object::Reference(font_id));\n                    res.set(\"Font\", Object::Dictionary(fonts));\n                }\n            }\n            if let Ok(page) = doc.get_dictionary_mut(*page_id) {\n                let mut contents = match page.get(b\"Contents\") {\n                    Ok(Object::Reference(r)) => vec![Object::Reference(*r)],\n                    Ok(Object::Array(a)) => a.clone(),\n                    _ => vec![],\n                };","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_form.rs#L711-L747","documentation":"This is an anyhow-wrapped failure from the Content::encode() call inside flatten (pdf_form.rs). Encoding the PDF content stream of drawing operations for flattened form-field text failed, so the operation aborts with the underlying lopdf error message prefixed by 'conteúdo:'.","triggerScenarios":"Calling fill->flatten on a form PDF where draw_ops produced operations that lopdf's Content::encode cannot serialize (e.g. malformed operator arguments, invalid text/rect data, or an encoding edge case in lopdf).","commonSituations":"Flattening filled AcroForm fields whose text values contain characters the chosen font/encoding cannot represent, or rects derived from widgets with unusual values.","solutions":["Inspect the wrapped lopdf error after 'conteúdo:' to find the failing operation","Sanitize/normalize field text (escape parentheses/backslashes, drop unencodable characters) before draw_ops","Update lopdf to the latest version for encode() fixes","Guard the encode call and skip that field's ops instead of failing the whole flatten"],"exampleFix":"// before\nlet data = Content { operations: ops }.encode().map_err(|e| anyhow!(\"conteúdo: {}\", e))?;\n// after\nlet data = Content { operations: ops }.encode().unwrap_or_default(); // or fall back to empty stream and warn","handlingStrategy":"try-catch","validationCode":"// Rust: pre-check ops encode without failing the whole flow\nlet data = Content { operations: ops.clone() }.encode();\nif data.is_err() { /* drop or fix ops before calling fill/flatten */ }","typeGuard":null,"tryCatchPattern":"match flatten_result {\n    Err(e) if e.to_string().starts_with(\"conteúdo:\") => warn!(\"content encode failed: {}\", e),\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Sanitize form-field text (escape PDF string specials) before building ops","Keep lopdf updated","Test flatten on PDFs with unicode-heavy field values"],"tags":["pdf","lopdf","content-stream","encoding"],"backgroundTag":"json-marshal-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}