Skip to main content

tests codecov pypi license contributors pypi-downloads Open in Streamlit

Brazil Fiscal Report

Python library for generating Brazilian auxiliary fiscal documents in PDF from XML documents.

Every Brazilian electronic invoice is issued by the tax authority as an XML file. This library turns that XML into the official, printable PDF that has to accompany the goods or service: NF-e → DANFE, CT-e → DACTE, MDF-e → DAMDFE, NFS-e → DANFSe and NFC-e → DANFCe. It also renders the DACCe, the printout for the NF-e correction-letter event (CC-e).

🇧🇷 Biblioteca Python para gerar em PDF os documentos fiscais auxiliares — DANFE, DACTE, DAMDFE, DANFSe e DANFCe — a partir do XML de NF-e, CT-e, MDF-e, NFS-e e NFC-e. Também gera a DACCe, representação da carta de correção (CC-e) da NF-e. Documentação em português →

Documentation | PyPI | Try it Online

Output Examples

DANFE DACTE DAMDFE DANFSe DANFCe
DANFE generated in PDF DACTE generated in PDF DAMDFE generated in PDF DANFSe generated in PDF DANFCe generated in PDF
NF-e → PDF
Electronic invoice (goods)
CT-e → PDF
Freight bill
MDF-e → PDF
Cargo manifest
NFS-e → PDF
Service invoice
NFC-e → PDF
Consumer receipt

Why BrazilFiscalReport?

  • 🐍 Pure Python — built on fpdf2; no wkhtmltopdf, no headless browser, no HTML templates
  • 📄 5 document types — DANFE, DACTE, DAMDFE, DANFSe and DANFCe (plus the DACCe correction-letter event), straight from the official XML
  • 🎨 Customizable — issuer logo, margins, fonts, decimal precision, cancellation watermarks and more
  • ⚡ 3 ways to use it — Python API, bfrep command line, or the online demo
  • ✅ Python 3.10+ — tested on Python 3.10 through 3.14

Installation

pip install brazilfiscalreport

This installs every document type. For the bfrep command line tool:

pip install 'brazilfiscalreport[cli]'

The dacte, damdfe, danfse and danfce extras are no longer needed; they are kept so existing install commands keep working.

Quick Start

from brazilfiscalreport.danfe import Danfe

with open("nfe.xml", "r", encoding="utf8") as file:
    xml_content = file.read()

danfe = Danfe(xml=xml_content)
danfe.output("danfe.pdf")

nfe.xml is the authorized XML your ERP or the SEFAZ portal returns once the invoice is approved.

The same pattern works for every document type — import the matching class (Dacte, Damdfe, Danfse, Danfce, DaCCe), pass the XML and call .output().

Customization

Need a logo, custom margins or a different font? Pass a config object:

from brazilfiscalreport.danfe import Danfe, DanfeConfig, Margins, FontType

with open("nfe.xml", encoding="utf8") as file:
    xml_content = file.read()

config = DanfeConfig(
    logo="logo.png",
    margins=Margins(top=5, right=5, bottom=5, left=5),
    font_type=FontType.TIMES,
)
danfe = Danfe(xml=xml_content, config=config)
danfe.output("danfe.pdf")

See the documentation for every option — watermarks, decimal precision, receipt position and more.

🚀 No setup? Try it online — upload your fiscal XML or pick a sample, then download the PDF.

CLI

pip install 'brazilfiscalreport[cli]'

bfrep danfe nfe.xml        # writes nfe.pdf in the current folder

bfrep ships one subcommand per document — danfe, dacte, damdfe, danfse and danfce (plus dacce for the NF-e correction letter and danfe-etiqueta for the DANFE Simplificado – Etiqueta) — each turning its XML into the matching PDF. Drop a config.yaml next to your files to set issuer data, logo and margins.

See the CLI documentation for all options.

License

BrazilFiscalReport is free software licensed under the LGPL-3.0 license.

Maintainer

Developed and maintained by Engenere. Issues and pull requests are welcome — see the contributing guide.

Metadata

Release files for BrazilFiscalReport 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BrazilFiscalReport 1.4.0
File Size Uploaded Provenance Actions
brazilfiscalreport-1.4.0.tar.gz 276.3 kB Without provenance Details for brazilfiscalreport-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BrazilFiscalReport 1.4.0
File Interpreter ABI Platform Actions
brazilfiscalreport-1.4.0-py3-none-any.whl Python 3 none any Details for brazilfiscalreport-1.4.0-py3-none-any.whl

Total release size: 541.6 kB

Release files / brazilfiscalreport-1.4.0.tar.gz

Download URL brazilfiscalreport-1.4.0.tar.gz
Size 276.3 kB
Tags Source
SHA-256 checksum
How to use checksums
73b2cbaa5858bcace2f83cdf7d7992d854ff6b30fe9c05d563538b97ef0abaef
BLAKE2b-256 checksum
How to use checksums
ba778e1ad743c354b5152749cdf46d9c4eb03d5117c33251f7149ae20543c2f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / brazilfiscalreport-1.4.0-py3-none-any.whl

Download URL brazilfiscalreport-1.4.0-py3-none-any.whl
Size 265.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5abc514edc827f90e0819ac0005ebe3eeb413872df42fe76f8616863894e6bb
BLAKE2b-256 checksum
How to use checksums
b4d0ab6b50b2f934b86c6bbdb96d379e2fe0ccffdcf4e826a7825d3307dd08e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for BrazilFiscalReport 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page