{"record":{"id":"a4992b28b361d490","repo":"tonhowtf/omniget","slug":"p-gina","errorCode":null,"errorMessage":"página: {}","messagePattern":"página: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_redact.rs","lineNumber":651,"sourceCode":"                    Object::Real(h),\n                    Object::Real(media[0]),\n                    Object::Real(media[1]),\n                ],\n            ),\n            Operation::new(\"Do\", vec![\"OGRXimg\".into()]),\n            Operation::new(\"Q\", vec![]),\n        ],\n    };\n    let stream_id = doc.add_object(Stream::new(\n        dictionary! {},\n        content.encode().map_err(|e| anyhow!(\"conteúdo: {}\", e))?,\n    ));\n    let res_id = doc.add_object(Object::Dictionary(dictionary! {\n        \"XObject\" => dictionary! { \"OGRXimg\" => Object::Reference(img_id) },\n    }));\n    let page = doc\n        .get_dictionary_mut(page_id)\n        .map_err(|e| anyhow!(\"página: {}\", e))?;\n    page.set(\"Contents\", Object::Reference(stream_id));\n    page.set(\"Resources\", Object::Reference(res_id));\n    page.remove(b\"Annots\");\n    Ok(())\n}\n\n/// Tira as anotações que encostam na região: um campo de formulário ou uma\n/// nota grudada ali carrega o texto de novo.\nfn drop_annots(doc: &mut Document, page_id: lopdf::ObjectId, rects: &[Rect]) {\n    let annots = match doc.get_dictionary(page_id).and_then(|p| p.get(b\"Annots\")) {\n        Ok(Object::Array(a)) => a.clone(),\n        Ok(Object::Reference(r)) => match doc.get_object(*r) {\n            Ok(Object::Array(a)) => a.clone(),\n            _ => return,\n        },\n        _ => return,\n    };\n    let hits = |dict: &lopdf::Dictionary| -> bool {","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_redact.rs#L633-L669","documentation":"In rasterize_page (pdf_redact.rs), after adding the rasterized stream, doc.get_dictionary_mut(page_id) failed, wrapped as 'página: {}'. The page object could not be fetched as a mutable dictionary, so the content/resources cannot be swapped in.","triggerScenarios":"page_id no longer resolves (freed/rewritten object), the page object is not a dictionary (e.g. an indirect reference chain lopdf won't follow), or the id belongs to another object after earlier mutations.","commonSituations":"Redacting pages of an unusual/corrupt PDF whose page tree lopdf parses imperfectly; object renumbering during save/load cycles invalidating stored ids.","solutions":["Re-resolve the page id from doc.get_pages() just before mutation instead of caching ids","Check the wrapped lopdf error for 'object not found' vs type errors","Run a repair/rewrite pass (load and save with lopdf) on suspect PDFs before redacting"],"exampleFix":"// before\nlet page = doc.get_dictionary_mut(page_id).map_err(|e| anyhow!(\"página: {}\", e))?;\n// after\nlet pages = doc.get_pages();\nif !pages.values().any(|id| *id == page_id) { bail!(\"page object {} missing\", page_id.0); }\nlet page = doc.get_dictionary_mut(page_id).map_err(|e| anyhow!(\"página: {}\", e))?;","handlingStrategy":"type-guard","validationCode":"let page_ids: Vec<_> = doc.get_pages().into_values().collect();\nif !page_ids.contains(&page_id) { bail!(\"page id {:?} not in document\", page_id); }","typeGuard":"fn page_is_dict(doc: &lopdf::Document, id: lopdf::ObjectId) -> bool {\n    matches!(doc.get_object(id), Ok(lopdf::Object::Dictionary(_)))\n}","tryCatchPattern":null,"preventionTips":["Re-resolve page ids from get_pages() right before mutation","Avoid caching object ids across load/save cycles","Run documents through a load+save normalization for exotic PDFs"],"tags":["pdf","lopdf","page-object"],"backgroundTag":"entity-not-found","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"}