tonhowtf/omniget · error

PDFium nao esta instalado (Ajustes → Dependencias → PDFium)

Error message

PDFium nao esta instalado (Ajustes → Dependencias → PDFium)

What it means

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).

Solutions

  1. Install PDFium via the app's dependency manager (Ajustes → Dependências → PDFium) before PDF operations
  2. Check resolve_path's search locations and place the PDFium .so/.dylib/.dll in one of them (e.g. beside the executable)
  3. Set the configured PDFium path / relevant env var to the library location
  4. Ship/bundle PDFium with the app installer so it is present out of the box

Example fix

// before
let text = pdf::info(path)?; // 'PDFium nao esta instalado'
// after
if crate::core::pdfium::resolve_path().is_none() {
    prompt_install_pdfium()?; // guide user to Ajustes → Dependências
}
let text = pdf::info(path)?;
Defensive patterns

Strategy: try-catch

Validate before calling

if crate::core::pdfium::resolve_path().is_none() {
    eprintln!("PDFium não instalado. Instale em Ajustes → Dependências → PDFium antes de usar recursos de PDF.");
    return;
}

Try / catch

match pdf::merge(&inputs, &out) {
    Err(e) if e.to_string().contains("PDFium nao esta instalado") => {
        show_install_pdfium_dialog(); // offer the built-in dependency installer
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/88b9044d69e29d93. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:124

unsafe fn sym<T: Copy>(lib: &libloading::Library, name: &[u8]) -> anyhow::Result<T> {
    Ok(*lib
        .get::<T>(name)
        .map_err(|e| anyhow!("PDFium sem {}: {}", String::from_utf8_lossy(name), e))?)
}

/// Igual ao `sym`, mas o símbolo pode faltar: devolve `None` em vez de erro.
unsafe fn opt_sym<T: Copy>(lib: &libloading::Library, name: &[u8]) -> Option<T> {
    lib.get::<T>(name).ok().map(|s| *s)
}

fn api() -> anyhow::Result<&'static Api> {
    let mut guard = API.lock().unwrap_or_else(|p| p.into_inner());
    if let Some(a) = *guard {
        return Ok(a);
    }
    let path = crate::core::pdfium::resolve_path()
        .ok_or_else(|| anyhow!("PDFium nao esta instalado (Ajustes → Dependencias → PDFium)"))?;
    let lib = unsafe { libloading::Library::new(&path) }
        .map_err(|e| anyhow!("nao carregou o PDFium em {}: {}", path.display(), e))?;
    let api = unsafe {
        let init: unsafe extern "C" fn() = sym(&lib, b"FPDF_InitLibrary\0")?;
        init();
        Api {
            load_mem: sym(&lib, b"FPDF_LoadMemDocument64\0")?,
            last_error: sym(&lib, b"FPDF_GetLastError\0")?,
            page_count: sym(&lib, b"FPDF_GetPageCount\0")?,
            load_page: sym(&lib, b"FPDF_LoadPage\0")?,
            page_w: sym(&lib, b"FPDF_GetPageWidthF\0")?,
            page_h: sym(&lib, b"FPDF_GetPageHeightF\0")?,
            close_page: sym(&lib, b"FPDF_ClosePage\0")?,
            close_doc: sym(&lib, b"FPDF_CloseDocument\0")?,
            bmp_create: sym(&lib, b"FPDFBitmap_Create\0")?,
            bmp_fill: sym(&lib, b"FPDFBitmap_FillRect\0")?,
            render: sym(&lib, b"FPDF_RenderPageBitmap\0")?,
            bmp_buffer: sym(&lib, b"FPDFBitmap_GetBuffer\0")?,

View on GitHub (pinned to 8600b91f42)