{"record":{"id":"88b9044d69e29d93","repo":"tonhowtf/omniget","slug":"pdfium-nao-esta-instalado-ajustes-dependencias-pdfium","errorCode":null,"errorMessage":"PDFium nao esta instalado (Ajustes → Dependencias → PDFium)","messagePattern":"PDFium nao esta instalado \\(Ajustes → Dependencias → PDFium\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":124,"sourceCode":"\nunsafe fn sym<T: Copy>(lib: &libloading::Library, name: &[u8]) -> anyhow::Result<T> {\n    Ok(*lib\n        .get::<T>(name)\n        .map_err(|e| anyhow!(\"PDFium sem {}: {}\", String::from_utf8_lossy(name), e))?)\n}\n\n/// Igual ao `sym`, mas o símbolo pode faltar: devolve `None` em vez de erro.\nunsafe fn opt_sym<T: Copy>(lib: &libloading::Library, name: &[u8]) -> Option<T> {\n    lib.get::<T>(name).ok().map(|s| *s)\n}\n\nfn api() -> anyhow::Result<&'static Api> {\n    let mut guard = API.lock().unwrap_or_else(|p| p.into_inner());\n    if let Some(a) = *guard {\n        return Ok(a);\n    }\n    let path = crate::core::pdfium::resolve_path()\n        .ok_or_else(|| anyhow!(\"PDFium nao esta instalado (Ajustes → Dependencias → PDFium)\"))?;\n    let lib = unsafe { libloading::Library::new(&path) }\n        .map_err(|e| anyhow!(\"nao carregou o PDFium em {}: {}\", path.display(), e))?;\n    let api = unsafe {\n        let init: unsafe extern \"C\" fn() = sym(&lib, b\"FPDF_InitLibrary\\0\")?;\n        init();\n        Api {\n            load_mem: sym(&lib, b\"FPDF_LoadMemDocument64\\0\")?,\n            last_error: sym(&lib, b\"FPDF_GetLastError\\0\")?,\n            page_count: sym(&lib, b\"FPDF_GetPageCount\\0\")?,\n            load_page: sym(&lib, b\"FPDF_LoadPage\\0\")?,\n            page_w: sym(&lib, b\"FPDF_GetPageWidthF\\0\")?,\n            page_h: sym(&lib, b\"FPDF_GetPageHeightF\\0\")?,\n            close_page: sym(&lib, b\"FPDF_ClosePage\\0\")?,\n            close_doc: sym(&lib, b\"FPDF_CloseDocument\\0\")?,\n            bmp_create: sym(&lib, b\"FPDFBitmap_Create\\0\")?,\n            bmp_fill: sym(&lib, b\"FPDFBitmap_FillRect\\0\")?,\n            render: sym(&lib, b\"FPDF_RenderPageBitmap\\0\")?,\n            bmp_buffer: sym(&lib, b\"FPDFBitmap_GetBuffer\\0\")?,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L106-L142","documentation":"The pdf module's api() lazily loads PDFium once, and returns this error when crate::core::pdfium::resolve_path() finds no PDFium shared library on the system. Without the native PDFium library none of the PDF operations can run. The message directs the user to the app's dependency installer (Ajustes → Dependências → PDFium).","triggerScenarios":"Calling any PDF command (info, merge, split, render, ink_boxes, redaction_check) before PDFium is installed; PDFium uninstalled or moved; resolve_path's search locations (app dir, configured path, system dirs) all miss.","commonSituations":"Fresh install where optional dependencies were never downloaded; Linux system without the libpdfium package; user deleted or relocated the bundled pdfium dynamic library; sandboxed environment where the search paths differ.","solutions":["Install PDFium via the app's dependency manager (Ajustes → Dependências → PDFium) before PDF operations","Check resolve_path's search locations and place the PDFium .so/.dylib/.dll in one of them (e.g. beside the executable)","Set the configured PDFium path / relevant env var to the library location","Ship/bundle PDFium with the app installer so it is present out of the box"],"exampleFix":"// before\nlet text = pdf::info(path)?; // 'PDFium nao esta instalado'\n// after\nif crate::core::pdfium::resolve_path().is_none() {\n    prompt_install_pdfium()?; // guide user to Ajustes → Dependências\n}\nlet text = pdf::info(path)?;","handlingStrategy":"try-catch","validationCode":"if crate::core::pdfium::resolve_path().is_none() {\n    eprintln!(\"PDFium não instalado. Instale em Ajustes → Dependências → PDFium antes de usar recursos de PDF.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"match pdf::merge(&inputs, &out) {\n    Err(e) if e.to_string().contains(\"PDFium nao esta instalado\") => {\n        show_install_pdfium_dialog(); // offer the built-in dependency installer\n    }\n    other => other?,\n}","preventionTips":["Check PDFium availability at app startup and disable PDF features until installed","Guide users to the in-app dependency installer instead of manual downloads","Bundle PDFium with the installer where licensing allows","Log resolve_path search locations to ease support tickets"],"tags":["rust","pdfium","missing-dependency","native-library","optional-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}