tonhowtf/omniget · error
conteúdo
Error message
conteúdo: {} What it means
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:'.
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
Example fix
// before
let data = Content { operations: ops }.encode().map_err(|e| anyhow!("conteúdo: {}", e))?;
// after
let data = Content { operations: ops }.encode().unwrap_or_default(); // or fall back to empty stream and warn Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: pre-check ops encode without failing the whole flow
let data = Content { operations: ops.clone() }.encode();
if data.is_err() { /* drop or fix ops before calling fill/flatten */ } Try / catch
match flatten_result {
Err(e) if e.to_string().starts_with("conteúdo:") => warn!("content encode failed: {}", e),
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Sanitize form-field text (escape PDF string specials) before building ops
- Keep lopdf updated
- Test flatten on PDFs with unicode-heavy field values
When it happens
Trigger: 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).
Common situations: Flattening filled AcroForm fields whose text values contain characters the chosen font/encoding cannot represent, or rects derived from widgets with unusual values.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/08386cd64743a1ea.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf_form.rs:729
font_size: f32,
) -> anyhow::Result<()> {
let ids: Vec<(u32, ObjectId)> = doc.get_pages().into_iter().collect();
let font_id = doc.add_object(dictionary! {
"Type" => "Font",
"Subtype" => "Type1",
"BaseFont" => "Helvetica",
"Encoding" => "WinAnsiEncoding",
});
for (no, page_id) in &ids {
let ops: Vec<Operation> = stamps
.iter()
.filter(|(p, ..)| *p == *no as usize)
.flat_map(|(_, rect, text, multi)| draw_ops(text, *rect, font_size, *multi))
.collect();
if !ops.is_empty() {
let data = Content { operations: ops }
.encode()
.map_err(|e| anyhow!("conteúdo: {}", e))?;
let stream_id = doc.add_object(Stream::new(dictionary! {}, data));
if let Some(res_id) = resource_dict_id(doc, *page_id) {
if let Ok(res) = doc.get_dictionary_mut(res_id) {
let mut fonts = res
.get(b"Font")
.and_then(Object::as_dict)
.cloned()
.unwrap_or_default();
fonts.set("OGFFfont", Object::Reference(font_id));
res.set("Font", Object::Dictionary(fonts));
}
}
if let Ok(page) = doc.get_dictionary_mut(*page_id) {
let mut contents = match page.get(b"Contents") {
Ok(Object::Reference(r)) => vec![Object::Reference(*r)],
Ok(Object::Array(a)) => a.clone(),
_ => vec![],
};View on GitHub (pinned to 8600b91f42)