### Clone Repository and Setup Virtual Environment Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Clone the project repository and set up a Python virtual environment for development. Activate the environment before installing dependencies. ```bash git clone https://github.com/Engenere/BrazilFiscalReport.git cd BrazilFiscalReport python -m venv .venv source .venv/bin/activate ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Install the project's core dependencies along with development and testing tools. Use the editable install option for the project itself. ```bash pip install -e '.[dacte,damdfe,cli]' pip install pytest pytest-cov ruff ``` -------------------------------- ### Example Configuration File (config.yaml) Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Example `config.yaml` file for configuring issuer details, logo path, and margins. The ISSUER section is specific to the `dacce` command, while LOGO and margins apply to DANFE, DACTE, and DAMDFE. ```yaml ISSUER: nome: "EMPRESA LTDA" end: "AV. TEST, 100" bairro: "CENTRO" cep: "01010-000" cidade: "SÃO PAULO" uf: "SP" fone: "(11) 1234-5678" LOGO: "/path/to/logo.jpg" TOP_MARGIN: 5.0 RIGHT_MARGIN: 5.0 BOTTOM_MARGIN: 5.0 LEFT_MARGIN: 5.0 ``` -------------------------------- ### Install Brazil Fiscal Report Source: https://github.com/engenere/brazilfiscalreport/blob/main/README.md Install the core library using pip. Optional extras can be installed for specific document types or the CLI tool. ```bash pip install brazilfiscalreport ``` ```bash pip install 'brazilfiscalreport[dacte]' ``` ```bash pip install 'brazilfiscalreport[damdfe]' ``` ```bash pip install 'brazilfiscalreport[danfse]' ``` ```bash pip install 'brazilfiscalreport[cli]' ``` ```bash pip install 'brazilfiscalreport[dacte,damdfe,danfse,cli]' ``` -------------------------------- ### Install Brazil Fiscal Report CLI Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Install the CLI with necessary dependencies using pip. ```bash pip install 'brazilfiscalreport[cli]' ``` -------------------------------- ### Generate Customized DAMDFE Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/damdfe.md Complete example demonstrating how to apply multiple configuration settings to a DAMDFE instance. ```python from brazilfiscalreport.damdfe import ( Damdfe, DamdfeConfig, DecimalConfig, FontType, Margins, ) # Path to the XML file xml_file_path = 'mdfe.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Create a configuration instance config = DamdfeConfig( logo='path/to/logo.png', margins=Margins(top=10, right=10, bottom=10, left=10), decimal_config=DecimalConfig(price_precision=2, quantity_precision=2), font_type=FontType.TIMES, ) # Use this config when creating a Damdfe instance damdfe = Damdfe(xml_content, config=config) damdfe.output('output_damdfe.pdf') ``` -------------------------------- ### Install qpdf for PDF Tests Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Install the qpdf utility, which is required for PDF comparison tests. This command is for Debian/Ubuntu-based systems. ```bash sudo apt-get install qpdf ``` -------------------------------- ### Install optional dependencies Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/getting-started.md Installs specific extras for DACTE, DAMDFE, CLI support, or all available features. ```bash pip install 'brazilfiscalreport[dacte]' ``` ```bash pip install 'brazilfiscalreport[damdfe]' ``` ```bash pip install 'brazilfiscalreport[cli]' ``` ```bash pip install 'brazilfiscalreport[dacte,damdfe,cli]' ``` -------------------------------- ### Apply Full DACTE Customization Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacte.md Example demonstrating how to initialize a DacteConfig object with multiple custom settings and apply it to a Dacte instance. ```python from brazilfiscalreport.dacte import ( Dacte, DacteConfig, DecimalConfig, FontType, Margins, ReceiptPosition, ) # Path to the XML file xml_file_path = 'cte.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Create a configuration instance config = DacteConfig( logo='path/to/logo.png', margins=Margins(top=10, right=10, bottom=10, left=10), receipt_pos=ReceiptPosition.BOTTOM, decimal_config=DecimalConfig(price_precision=2, quantity_precision=2), font_type=FontType.TIMES, ) # Use this config when creating a Dacte instance dacte = Dacte(xml_content, config=config) dacte.output('output_dacte.pdf') ``` -------------------------------- ### Install brazilfiscalreport core library Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/getting-started.md Installs the core library with support for DANFE and DACCe. ```bash pip install brazilfiscalreport ``` -------------------------------- ### Install and Configure Pre-commit Hooks Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Install the pre-commit package to manage and run Git hooks. This ensures code style and quality checks are performed automatically before each commit. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Generate DANFE PDF from XML Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/getting-started.md Full example showing how to load an NF-e XML file and generate a DANFE PDF. ```python from brazilfiscalreport.danfe import Danfe # Load the XML content with open("nfe.xml", "r", encoding="utf8") as file: xml_content = file.read() # Generate the PDF danfe = Danfe(xml=xml_content) danfe.output("danfe.pdf") ``` -------------------------------- ### Check Brazil Fiscal Report Version Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Verify the installed version of the CLI using the `--version` or `-v` option. ```bash bfrep --version ``` -------------------------------- ### Customize DACCe with Issuer Information Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacce.md This example shows how to customize the DACCe PDF by providing issuer details. The `emitente` dictionary must contain specific keys for the address and contact information. ```Python emitente = { "nome": "EMPRESA LTDA", "end": "AV. TEST, 100", "bairro": "CENTRO", "cidade": "SÃO PAULO", "uf": "SP", "fone": "(11) 1234-5678", } ``` -------------------------------- ### Danfe with Custom Configuration Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md This snippet shows how to load an XML file and create a Danfe instance with a comprehensive set of custom configurations. It covers setting margins, decimal precision, tax display, invoice details, font types, and footer stamps. Use this when you need fine-grained control over the generated PDF's appearance and content. ```python from brazilfiscalreport.danfe import ( Danfe, DanfeConfig, DecimalConfig, FontType, FooterStamp, InvoiceDisplay, Margins, ProductDescriptionConfig, ReceiptPosition, TaxConfiguration, ) # Path to the XML file xml_file_path = 'nfe.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Create a configuration instance config = DanfeConfig( logo='path/to/logo.png', margins=Margins(top=10, right=10, bottom=10, left=10), receipt_pos=ReceiptPosition.BOTTOM, decimal_config=DecimalConfig(price_precision=2, quantity_precision=2), tax_configuration=TaxConfiguration.ICMS_ST, invoice_display=InvoiceDisplay.FULL_DETAILS, font_type=FontType.TIMES, display_pis_cofins=True, product_description_config=ProductDescriptionConfig( display_branch=True, display_additional_info=True, ), footer_stamp=FooterStamp( logo='path/to/footer_logo.png', text='Powered by', ), ) # Use this config when creating a Danfe instance danfe = Danfe(xml_content, config=config) danfe.output('output_danfe.pdf') ``` -------------------------------- ### Generate fiscal documents via CLI Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/getting-started.md Quick generation of fiscal documents directly from the terminal. ```bash bfrep danfe /path/to/nfe.xml bfrep dacce /path/to/cce.xml bfrep dacte /path/to/cte.xml bfrep damdfe /path/to/mdfe.xml ``` -------------------------------- ### Configure Product Description Display Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Customize the information displayed in the product description column of the Danfe, including branch, ANP, ANVISA, and additional info. Defaults vary per field. ```python config.product_description_config = ProductDescriptionConfig( display_branch=True, branch_info_prefix="=>", display_additional_info=True, display_anp=True, display_anvisa=True, ) ``` -------------------------------- ### Generate PDFs using CLI Source: https://github.com/engenere/brazilfiscalreport/blob/main/README.md The CLI tool 'bfrep' allows generating PDFs directly from the terminal by specifying the document type and the path to the XML file. ```bash bfrep danfe /path/to/nfe.xml ``` ```bash bfrep dacte /path/to/cte.xml ``` ```bash bfrep damdfe /path/to/mdfe.xml ``` ```bash bfrep dacce /path/to/cce.xml ``` ```bash bfrep danfse /path/to/nfse.xml ``` -------------------------------- ### Generate DACTE, DAMDFE, and DACCe PDFs Source: https://github.com/engenere/brazilfiscalreport/blob/main/README.md The pattern for generating PDFs is consistent across different document types. Instantiate the respective class (Dacte, Damdfe, DaCCe) with the XML content and call the output method. ```python from brazilfiscalreport.dacte import Dacte from brazilfiscalreport.damdfe import Damdfe from brazilfiscalreport.dacce import DaCCe dacte = Dacte(xml=cte_xml) dacte.output("dacte.pdf") damdfe = Damdfe(xml=mdfe_xml) damdfe.output("damdfe.pdf") dacce = DaCCe(xml=cce_xml) dacce.output("dacce.pdf") ``` -------------------------------- ### Set Danfe Logo from File Path Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Configure the Danfe to include a logo by specifying the file path. Ensure the file exists at the given location. ```python config.logo = "path/to/logo.jpg" # Using a file path ``` -------------------------------- ### Configure DAMDFE Output Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/damdfe.md Individual configuration options for customizing the appearance and formatting of the generated PDF. ```python config.logo = "path/to/logo.jpg" # Using a file path ``` ```python config.margins = Margins(top=10, right=10, bottom=10, left=10) ``` ```python config.decimal_config = DecimalConfig(price_precision=2, quantity_precision=2) ``` ```python config.font_type = FontType.COURIER ``` -------------------------------- ### Generate DAMDFE PDF Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/damdfe.md Basic methods to generate a DAMDFE PDF from an XML file using either the Python library or the command-line interface. ```python from brazilfiscalreport.damdfe import Damdfe # Path to the XML file xml_file_path = 'mdfe.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') ``` ```bash bfrep damdfe /path/to/mdfe.xml ``` -------------------------------- ### DaCCe Class Initialization Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacce.md Initializes the DaCCe object to generate a PDF from CC-e XML content, supporting optional issuer details and logo customization. ```APIDOC ## DaCCe Initialization ### Description Initializes the DaCCe class to process CC-e XML data and generate a PDF document. ### Parameters - **xml** (str) - Required - The XML content of the CC-e event. - **emitente** (dict) - Optional - Dictionary containing issuer information (nome, end, bairro, cidade, uf, fone). - **image** (str/BytesIO/bytes) - Optional - Path to a logo image file or binary image data. ### Request Example ```python from brazilfiscalreport.dacce import DaCCe emitente = { "nome": "EMPRESA LTDA", "end": "AV. TEST, 100", "bairro": "CENTRO", "cidade": "SÃO PAULO", "uf": "SP", "fone": "(11) 1234-5678", } cce = DaCCe(xml=xml_content, emitente=emitente, image="path/to/logo.png") ``` ``` -------------------------------- ### Generate DANFSE PDF using CLI Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Generate a DANFSE PDF directly from the command line interface by providing the path to the XML file. ```Bash bfrep danfse /path/to/nfse.xml ``` -------------------------------- ### CLI Command for DaCCe Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacce.md Command line interface usage for generating a DaCCe PDF from an XML file. ```APIDOC ## CLI: Generate DaCCe ### Description Generates a DaCCe PDF file directly from the command line using an XML input file. ### Usage `bfrep dacce /path/to/cce.xml` ``` -------------------------------- ### Generate fiscal document PDFs Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/getting-started.md Standard pattern for generating various fiscal document types using their respective classes. ```python from brazilfiscalreport.danfe import Danfe danfe = Danfe(xml=xml_content) danfe.output("danfe.pdf") ``` ```python from brazilfiscalreport.dacce import DaCCe dacce = DaCCe(xml=xml_content) dacce.output("dacce.pdf") ``` ```python from brazilfiscalreport.dacte import Dacte dacte = Dacte(xml=xml_content) dacte.output("dacte.pdf") ``` ```python from brazilfiscalreport.damdfe import Damdfe damdfe = Damdfe(xml=xml_content) damdfe.output("damdfe.pdf") ``` -------------------------------- ### Run Project Tests with Pytest Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Execute all project tests using pytest. Options are available to run tests with code coverage or for specific modules. ```bash pytest pytest --cov=./brazilfiscalreport --cov-branch pytest tests/test_danfe.py ``` -------------------------------- ### Generate DANFE from XML using CLI Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Generates a DANFE PDF directly from the command line by providing the path to the NF-e XML file. ```bash bfrep danfe /path/to/nfe.xml ``` -------------------------------- ### Generate DACCe PDF from XML Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacce.md Use this snippet to load CC-e XML content and generate a DACCe PDF. Ensure the XML file is correctly formatted. ```Python from brazilfiscalreport.dacce import DaCCe # Path to the XML file xml_file_path = 'cce.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Instantiate the CC-e PDF object with the loaded XML content cce = DaCCe(xml=xml_content) # Save the generated PDF to a file cce.output('cce.pdf') ``` -------------------------------- ### Generate DACTE Document Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Generate a DACTE (Documento Auxiliar do Conhecimento de Transporte Eletrônico) from an XML file. This command respects LOGO and margin settings from `config.yaml`. ```bash bfrep dacte /path/to/cte.xml ``` -------------------------------- ### Generate DAMDFE Document Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Generate a DAMDFE (Documento Auxiliar do Manifesto Eletrônico de Documentos Fiscais) from an XML file. This command respects LOGO and margin settings from `config.yaml`. ```bash bfrep damdfe /path/to/mdfe.xml ``` -------------------------------- ### Generate DANFSE PDF from XML Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Load an XML file and generate a PDF output of the DANFSE. Ensure the XML file is correctly formatted according to the DANFSe v2.0 model. ```Python from brazilfiscalreport.danfse import Danfse # Path to the XML file xml_file_path = 'nfse.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Instantiate the DANFSE object with the loaded XML content danfse = Danfse(xml=xml_content) danfse.output('output_danfse.pdf') ``` -------------------------------- ### Generate DAMDFE PDF Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/damdfe.md Generates a PDF representation of the MDF-e from an XML file. ```APIDOC ## POST /damdfe ### Description Generates a DAMDFE PDF document from the provided MDF-e XML content. ### Method POST ### Endpoint /damdfe ### Request Body - **xml** (string) - Required - The raw XML content of the MDF-e. - **config** (DamdfeConfig) - Optional - Configuration object for PDF customization. ### Request Example { "xml": "...", "config": { "logo": "path/to/logo.png", "margins": {"top": 10, "right": 10, "bottom": 10, "left": 10}, "decimal_config": {"price_precision": 2, "quantity_precision": 2}, "font_type": "TIMES" } } ### Response #### Success Response (200) - **file** (binary) - The generated PDF document. ``` -------------------------------- ### Generate DACTE Document Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacte.md Basic methods to generate a DACTE PDF from an XML file using either the Python library or the command line interface. ```python from brazilfiscalreport.dacte import Dacte # Path to the XML file xml_file_path = 'cte.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Instantiate the DACTE object with the loaded XML content dacte = Dacte(xml=xml_content) dacte.output('output_dacte.pdf') ``` ```bash bfrep dacte /path/to/cte.xml ``` -------------------------------- ### Generate DACCe Document Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Generate a DACCe (Documento Auxiliar de Conhecimento de Transporte Eletrônico - Complemento) from an XML file. This command utilizes the ISSUER section from `config.yaml`. ```bash bfrep dacce /path/to/cce.xml ``` -------------------------------- ### Enable Display of PIS COFINS Taxes Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Set to True to display PIS and COFINS taxes in the Danfe totals. Defaults to False. ```python config.display_pis_cofins = True ``` -------------------------------- ### Generate DANFE Document Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/cli.md Generate a DANFE (Documento Auxiliar da Nota Fiscal Eletrônica) from an XML file. ```bash bfrep danfe /path/to/nfe.xml ``` -------------------------------- ### Customize DACCe with Issuer and Logo Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacce.md Generate a DACCe PDF with both issuer information and a custom logo. The `image` parameter accepts a file path or binary image data. ```Python from brazilfiscalreport.dacce import DaCCe # Path to the XML file xml_file_path = 'cce.xml' # Load XML Content with open(xml_file_path, "r", encoding="utf8") as file: xml_content = file.read() # Issuer information emitente = { "nome": "EMPRESA LTDA", "end": "AV. TEST, 100", "bairro": "CENTRO", "cidade": "SÃO PAULO", "uf": "SP", "fone": "(11) 1234-5678", } # Instantiate with issuer and logo cce = DaCCe(xml=xml_content, emitente=emitente, image="path/to/logo.png") # Save the generated PDF to a file cce.output('cce.pdf') ``` -------------------------------- ### Configure DACTE Output Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/dacte.md Individual configuration options for customizing the DACTE PDF appearance and data formatting. ```python config.logo = "path/to/logo.jpg" # Using a file path ``` ```python config.margins = Margins(top=5, right=5, bottom=5, left=5) ``` ```python config.receipt_pos = ReceiptPosition.BOTTOM ``` ```python config.decimal_config = DecimalConfig(price_precision=2, quantity_precision=2) ``` ```python config.font_type = FontType.COURIER ``` ```python config.watermark_cancelled = True ``` -------------------------------- ### Code Linting and Formatting with Ruff Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Manually check code for style issues and format the code using Ruff. These commands can be run directly in the terminal. ```bash ruff check . ruff format . ``` -------------------------------- ### Set Danfe Tax Configuration Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Choose which tax fields to display in the Danfe. Note: This feature is not yet implemented. ```python config.tax_configuration = TaxConfiguration.WITHOUT_IPI ``` -------------------------------- ### Regenerate Reference PDFs for Tests Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/contributing.md Regenerate the reference PDF files used in tests, typically when changes to PDF output have been intentionally made. This requires setting an environment variable. ```bash BFR_GENERATE_EXPECTED=1 pytest tests/test_danfe.py ``` -------------------------------- ### Enable Line Break in Supplementary Information Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Set to True to use a semicolon as a line break in the supplementary information (infCpl) of the Danfe. Defaults to False. ```python config.infcpl_semicolon_newline= True ``` -------------------------------- ### Configure Decimal Precision for Danfe Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Set the number of decimal places for prices and quantities in the Danfe. Defaults to 4. ```python config.decimal_config = DecimalConfig(price_precision=2, quantity_precision=2) ``` -------------------------------- ### Configure Footer Stamp Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Sets a custom stamp with a logo and text on every page of the invoice. The stamp is right-aligned to the page margin and automatically reserved within the bottom margin. ```python config.footer_stamp = FooterStamp( logo="path/to/logo.png", text="Powered by", ) ``` -------------------------------- ### Display Acknowledgment Stub (Canhoto) on DANFSE Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Enable the display of the acknowledgment stub (canhoto) at the bottom of the DANFSE PDF. This stub includes fields for acknowledgment date, signature, and NFS-e details. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig config = DanfseConfig(display_canhoto=True) ``` -------------------------------- ### Enable Cancelled Invoice Watermark Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md When True, displays a 'CANCELADA' watermark on the Danfe for cancelled invoices. Defaults to False. ```python config.watermark_cancelled = True ``` -------------------------------- ### Enable Replaced Watermark on DANFSE Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Add a 'SUBSTITUÍDA' watermark to the DANFSE PDF for replaced documents. Note that the 'CANCELADA' watermark takes precedence if both are enabled. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig config = DanfseConfig(watermark_replaced=True) ``` -------------------------------- ### Set Danfe Font Size Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Select the font size for the Danfe document, choosing between BIG or SMALL. Defaults to SMALL. ```python config.font_size = FontSize.BIG ``` -------------------------------- ### Set Danfe Invoice Display Mode Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Control the level of detail shown for invoices in the Danfe, choosing between full details or duplicates only. Defaults to FULL_DETAILS. ```python config.invoice_display = InvoiceDisplay.FULL_DETAILS ``` -------------------------------- ### Set Danfe Margins Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Define the top, right, bottom, and left margins for the Danfe PDF document in millimeters. Defaults are 5mm for all sides. ```python config.margins = Margins(top=5, right=5, bottom=5, left=5) ``` -------------------------------- ### Configure DANFSE Decimal Precision Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Set the decimal precision for monetary amounts and tax rates in the DANFSE PDF. The default is 2 decimal places. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig, DecimalConfig config = DanfseConfig(decimal_config=DecimalConfig(price_precision=2)) ``` -------------------------------- ### Set Danfe Receipt Position Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Specify the position of the receipt section within the Danfe. Note that in landscape orientation, it is fixed to the left. ```python config.receipt_pos = ReceiptPosition.BOTTOM ``` -------------------------------- ### Set Danfe Font Type Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfe.md Choose the font style for the Danfe document from predefined options like COURIER or TIMES. Defaults to TIMES. ```python config.font_type = FontType.COURIER ``` -------------------------------- ### Customize DANFSE Margins Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Adjust the PDF margins for the DANFSE output. The library defaults to 2 mm on all sides, adhering to NT 008/2026 requirements. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig, Margins config = DanfseConfig( margins=Margins(top=2, right=2, bottom=2, left=2) ) danfse = Danfse(xml=xml_content, config=config) danfse.output('output_danfse.pdf') ``` -------------------------------- ### Enable Cancelled Watermark on DANFSE Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Add a 'CANCELADA' watermark to the DANFSE PDF for cancelled documents. This follows the specifications in NT 008/2026. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig config = DanfseConfig(watermark_cancelled=True) danfse = Danfse(xml=xml_content, config=config) danfse.output('output_danfse.pdf') ``` -------------------------------- ### Set DANFSE Font Type Source: https://github.com/engenere/brazilfiscalreport/blob/main/docs/danfse.md Configure the font type for the DANFSE PDF. The default is Helvetica, which is a metric-equivalent PDF core font. ```Python from brazilfiscalreport.danfse import Danfse, DanfseConfig, FontType config = DanfseConfig(font_type=FontType.HELVETICA) # default danfse = Danfse(xml=xml_content, config=config) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.