Uma biblioteca Python para criar, compor, visualizar, manipular e aplicar OCR em PDFs.
Project description
RabbitPDF
RabbitPDF é uma biblioteca Python para criar, compor, visualizar, manipular e aplicar OCR em arquivos PDF.
Versão atual: 0.2.0.
Recursos
- Criar PDFs simples a partir de texto, linhas ou imagens.
- Compor documentos ricos com cabeçalho, rodapé, tabelas, imagens, marca d'água, numeração de páginas e estilos de texto.
- Ajustar fonte, tamanho, entrelinha, margens independentes, espaçamentos, bordas e padding de tabelas.
- Juntar, extrair, dividir, criptografar, descriptografar e marcar PDFs existentes.
- Abrir PDFs no visualizador local ou em uma página HTML simples.
- Executar OCR em PDFs digitalizados com dependências opcionais.
- Usar por API Python ou pela CLI
rabbitpdf.
Instalação
pip install RabbitPDF
Para OCR:
pip install "RabbitPDF[ocr]"
O OCR também exige o binário do Tesseract instalado no sistema.
Começo Rápido
from rabbitpdf import PDFCreator, PDFViewer
PDFCreator(title="Exemplo").create_from_text(
"Olá, RabbitPDF!",
"hello.pdf",
)
PDFViewer("hello.pdf").open()
Documento Avançado
from reportlab.lib.units import cm
from rabbitpdf import DocumentTheme, RabbitDocument, TableOptions, TextStyle
(
RabbitDocument(
title="Relatório",
page_size="A4",
left_margin=2.5 * cm,
right_margin=2.5 * cm,
top_margin=2.0 * cm,
bottom_margin=2.0 * cm,
theme=DocumentTheme(font_size=11, leading=14),
)
.add_paragraph("RELATÓRIO", bold=True, underline=True, align="center")
.add_spacer(16)
.add_table(
[
["Item", "Valor"],
["Subtotal", "R$ 100,00"],
["Total", "R$ 100,00"],
],
options=TableOptions(
repeat_header=True,
padding=6,
cell_style=TextStyle(font_size=10, leading=12, space_after=0),
),
)
.build("relatorio.pdf")
)
CLI
Criar PDF com texto:
rabbitpdf create hello.pdf --text "Olá, RabbitPDF"
Criar PDF a partir de imagens:
rabbitpdf create album.pdf --images pagina-1.png pagina-2.jpg
Juntar PDFs:
rabbitpdf merge final.pdf capa.pdf conteudo.pdf anexos.pdf
Extrair páginas:
rabbitpdf extract relatorio.pdf resumo.pdf --pages "1,3-5,-1"
Adicionar marca d'água:
rabbitpdf watermark entrada.pdf saida.pdf --text "CONFIDENCIAL"
Se o executável não estiver no PATH, use:
python -m rabbitpdf --help
Exemplos
Os exemplos ficam em examples:
- hello_document.py: documento visual com cabeçalho, texto, imagem placeholder e rodapé.
- relatorio_tabela.py: relatório com tabela estilizada.
- parecer_documental.py: parecer documental com fonte 11, tabela chave/valor, textos ricos e espaçamento calibrado.
- operacoes_pdf.py: criação, merge, marca d'água, extração e split de PDFs.
Execute qualquer exemplo com:
python examples/parecer_documental.py
Documentação
Desenvolvimento
python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check .
python -m build
python -m twine check dist/*
Também é possível rodar testes diretamente:
python tests/test_document.py
python tests/test_examples.py
Publicação
O workflow de publicação está em:
.github/workflows/publish.yml
No PyPI Trusted Publishing, informe o nome do workflow:
publish.yml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rabbitpdf-0.2.0.tar.gz.
File metadata
- Download URL: rabbitpdf-0.2.0.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ebddafc894d5b7286f84d77c6843ef36eef25a6920ec1039b5d379501991ac7
|
|
| MD5 |
19be441be91e0c84038574fc6fd63d56
|
|
| BLAKE2b-256 |
2e5cb2baed2c4177f6ee535a65fa2acaa33ce027e84a52c1ad13484198f767c3
|
Provenance
The following attestation bundles were made for rabbitpdf-0.2.0.tar.gz:
Publisher:
publish.yml on juca-soft/RabbitPDF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabbitpdf-0.2.0.tar.gz -
Subject digest:
4ebddafc894d5b7286f84d77c6843ef36eef25a6920ec1039b5d379501991ac7 - Sigstore transparency entry: 2089630426
- Sigstore integration time:
-
Permalink:
juca-soft/RabbitPDF@740872275f9982b8068e558c8c2b780c7a509c9a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/juca-soft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@740872275f9982b8068e558c8c2b780c7a509c9a -
Trigger Event:
release
-
Statement type:
File details
Details for the file rabbitpdf-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rabbitpdf-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09ac72ace603b3d1b0857372034671b1aa505b74a9a57946f4b4717539590e21
|
|
| MD5 |
e89d400392d0fa60d509a0ed2eafa472
|
|
| BLAKE2b-256 |
57343de6a3216fb0ae752201c61f430efda2a34760270bc360799535cd82900c
|
Provenance
The following attestation bundles were made for rabbitpdf-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on juca-soft/RabbitPDF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabbitpdf-0.2.0-py3-none-any.whl -
Subject digest:
09ac72ace603b3d1b0857372034671b1aa505b74a9a57946f4b4717539590e21 - Sigstore transparency entry: 2089630888
- Sigstore integration time:
-
Permalink:
juca-soft/RabbitPDF@740872275f9982b8068e558c8c2b780c7a509c9a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/juca-soft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@740872275f9982b8068e558c8c2b780c7a509c9a -
Trigger Event:
release
-
Statement type: