Impressão do MDFe - TadaSoftware/PyNFe GitHub Wiki

Instale a dependência da impressão do documentos fiscal:

pip install 'pynfe[impressao]'

ou diretamente:

pip install 'brazilfiscalreport[damdfe]'

Exemplo de código

from brazilfiscalreport.damdfe import Damdfe

# Path to the XML file
xml_file_path = 'damdfe.xml'

# Load XML Content
with open(xml_file_path, "r", encoding="utf8") as file:
    xml_content = file.read()

# Instantiate the DAMDFE object with the loaded XML content
damdfe = Damdfe(xml=xml_content)

# Save the generated PDF to a file
damdfe.output('damdfe.pdf')

Documentação