npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pdf-extractor-data

v1.0.3

Published

Addon nativo Node.js em C++ para extração de dados de PDF

Readme

extrator-dados-pdf

Addon nativo Node.js (C++/N-API) para extrair texto e metadados básicos de PDFs usando PDFium.

Requisitos

  • Node.js 18+ (recomendado 20+)
  • Python 3 (node-gyp)
  • Ferramentas de build C++
    • Windows: Visual Studio Build Tools 2022 (C++), MSVC x64
    • Linux/macOS: Clang/GCC e CMake (a validar)

Observação: este repositório inclui binários do PDFium para Windows x64 em pdfium/lib/win/x64. A DLL (pdfium.dll) é copiada automaticamente para a pasta de saída durante o build.

Instalação e build (local)

npm install
npm run build

Se alterar os fontes nativos, rode:

npm run rebuild

Build no Windows

  1. Instale o Visual Studio Build Tools 2022 (com workload de C++ / MSVC x64) e Python 3.
  2. Os binários do PDFium para Windows x64 já estão neste repositório em pdfium/lib/win/x64.
  3. Rode:
    npm install
    npm run build
    A pdfium.dll será copiada automaticamente para a pasta de saída do addon.

Build no Linux

  1. Instale as ferramentas de build:
    sudo apt-get update
    sudo apt-get install -y build-essential python3 make g++ cmake
    (Em outras distros, instale os equivalentes; iconv geralmente faz parte da glibc.)
  2. Coloque o libpdfium.so correspondente na árvore do projeto:
    • x64: pdfium/lib/linux/x64/lib/libpdfium.so
    • arm64: pdfium/lib/linux/arm64/lib/libpdfium.so
  3. Rode:
    npm install
    npm run build
    O build copia o libpdfium.so para a pasta de saída e define rpath para carregá-lo em runtime.

Suporte de plataforma (atual)

  • Windows x64: suportado
  • Linux/macOS: em planejamento

Uso básico

const { extractPdf } = require('extrator-dados-pdf'); // ou require('./') durante o desenvolvimento

const filePath = 'test/exemplo.pdf';

// Extração básica
const result = extractPdf(filePath);
console.log(result.metadata); // { title, author, pages }
console.log(result.pages[0].text); // texto da primeira página

// PDF com senha
const secured = extractPdf(filePath, { password: 'minha-senha' });

Retorno:

{
  metadata: {
    title: string,
    author: string,
    pages: number
  },
  pages: Array<{ page: number, text: string }>
}

Testes

Coloque um PDF de exemplo em test/exemplo.pdf e rode:

npm test

Estrutura

  • index.js: API JavaScript (carrega o addon nativo)
  • src/addon.cc: implementação C++ com PDFium
  • binding.gyp: configuração de build (link + cópia da DLL no Windows)
  • pdfium/: binários pré-compilados do PDFium (Windows x64) e libs
  • test/: testes de unidade/integração

Erros comuns

  • Falha ao abrir PDF: arquivo inexistente, corrompido ou senha incorreta
  • Dependências de build ausentes: confira Requisitos

Licença

Usa PDFium (BSD-3-Clause). Verifique compatibilidade conforme seu caso.