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 and NFS-e → DANFSe. 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 e DANFSe — a partir do XML de NF-e, CT-e, MDF-e e NFS-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
DANFE generated in PDF DACTE generated in PDF DAMDFE generated in PDF DANFSe generated in PDF
NF-e → PDF
Electronic invoice (goods)
CT-e → PDF
Freight bill
MDF-e → PDF
Cargo manifest
NFS-e → PDF
Service invoice

Why BrazilFiscalReport?

  • 🐍 Pure Python — built on fpdf2; no wkhtmltopdf, no headless browser, no HTML templates
  • 📄 4 document types — DANFE, DACTE, DAMDFE and DANFSe (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 the core library with support for DANFE and DACCe. For additional document types and features:

pip install 'brazilfiscalreport[dacte]'   # DACTE support (requires qrcode)
pip install 'brazilfiscalreport[damdfe]'  # DAMDFE support (requires qrcode)
pip install 'brazilfiscalreport[danfse]'  # DANFSe support (requires qrcode)
pip install 'brazilfiscalreport[cli]'     # CLI tool
pip install 'brazilfiscalreport[dacte,damdfe,danfse,cli]'  # All extras

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, 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, 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 and danfse (plus dacce for the NF-e correction letter) — 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.2.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.2.0
File Size Uploaded
brazilfiscalreport-1.2.0.tar.gz 231.6 kB Details

Built distribution (wheel)

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

Total release size: 459.0 kB

Release files / brazilfiscalreport-1.2.0.tar.gz

Download URL brazilfiscalreport-1.2.0.tar.gz
Size 231.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ddf91aeec13d701590648704163f47f369931844d788780f4cfc6659f40488cd
BLAKE2b-256 checksum
How to use checksums
c2df1697475c634504f9dc715c6f95e3ebc98586ce22189cb7730e66d121d6e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL brazilfiscalreport-1.2.0-py3-none-any.whl
Size 227.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac8119d0510773e30b23dd07421c2c622e9bf1843dde532cf5365b7fd6d17edc
BLAKE2b-256 checksum
How to use checksums
dad8784910dc8c172442d305645773ab65a0b46165a158acaa0e225fb5f75b6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.33

2 release files

0.5.32

2 release files

0.5.31

2 release files

0.5.30

2 release files

0.5.28

2 release files

0.5.27

2 release files

0.5.24

2 release files

0.5.23

2 release files

0.5.22

2 release files

0.5.21

2 release files

0.5.20

2 release files

0.5.19

2 release files

0.5.18

2 release files

0.5.17

2 release files

0.5.14

2 release files

0.5.13

2 release files

0.5.12

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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