PDF Generator¶
DANFSE PDF Generator - Generate PDF from NFSe XML.
This module generates DANFSE (Documento Auxiliar da NFS-e) PDFs from NFSe XML data, following the official layout pattern.
- class pynfse_nacional.pdf_generator.HeaderConfig¶
Bases:
objectConfiguration for custom header in DANFSE PDF.
- __init__(image_path=None, title='', subtitle='', phone='', email='')¶
- Parameters:
image_path (str | None)
title (str)
subtitle (str)
phone (str)
email (str)
- Return type:
None
- class pynfse_nacional.pdf_generator.NFSeData¶
Bases:
objectParsed NFSe data for PDF generation.
- __init__(chave_acesso='', numero_nfse='', competencia='', data_hora_emissao='', numero_dps='', serie_dps='', data_hora_dps='', emit_cnpj='', emit_cpf='', emit_im='', emit_nome='', emit_telefone='', emit_email='', emit_endereco='', emit_municipio='', emit_uf='', emit_cep='', emit_simples_nacional='', emit_regime_apuracao='', toma_cnpj='', toma_cpf='', toma_im='', toma_nome='', toma_telefone='', toma_email='', toma_endereco='', toma_municipio='', toma_uf='', toma_cep='', cod_trib_nac='', desc_trib_nac='', cod_trib_mun='', desc_trib_mun='', local_prestacao='', pais_prestacao='', descricao_servico='', trib_issqn='', pais_resultado='', mun_incidencia='', regime_especial='', tipo_imunidade='', suspensao_issqn='', num_processo_suspensao='', beneficio_municipal='', valor_servico='', desconto_incond='', total_deducoes='', calculo_bm='', bc_issqn='', aliquota='', retencao_issqn='', issqn_apurado='', irrf='', cp='', csll='', pis='', cofins='', retencao_pis_cofins='', total_trib_federal='', desconto_cond='', issqn_retido='', irrf_cp_csll_retidos='', pis_cofins_retidos='', valor_liquido='', trib_federais='', trib_estaduais='', trib_municipais='', nbs='', info_complementar='', ibscbs=None, ibscbs_totals=None)¶
- Parameters:
chave_acesso (str)
numero_nfse (str)
competencia (str)
data_hora_emissao (str)
numero_dps (str)
serie_dps (str)
data_hora_dps (str)
emit_cnpj (str)
emit_cpf (str)
emit_im (str)
emit_nome (str)
emit_telefone (str)
emit_email (str)
emit_endereco (str)
emit_municipio (str)
emit_uf (str)
emit_cep (str)
emit_simples_nacional (str)
emit_regime_apuracao (str)
toma_cnpj (str)
toma_cpf (str)
toma_im (str)
toma_nome (str)
toma_telefone (str)
toma_email (str)
toma_endereco (str)
toma_municipio (str)
toma_uf (str)
toma_cep (str)
cod_trib_nac (str)
desc_trib_nac (str)
cod_trib_mun (str)
desc_trib_mun (str)
local_prestacao (str)
pais_prestacao (str)
descricao_servico (str)
trib_issqn (str)
pais_resultado (str)
mun_incidencia (str)
regime_especial (str)
tipo_imunidade (str)
suspensao_issqn (str)
num_processo_suspensao (str)
beneficio_municipal (str)
valor_servico (str)
desconto_incond (str)
total_deducoes (str)
calculo_bm (str)
bc_issqn (str)
aliquota (str)
retencao_issqn (str)
issqn_apurado (str)
irrf (str)
cp (str)
csll (str)
pis (str)
cofins (str)
retencao_pis_cofins (str)
total_trib_federal (str)
desconto_cond (str)
issqn_retido (str)
irrf_cp_csll_retidos (str)
pis_cofins_retidos (str)
valor_liquido (str)
trib_federais (str)
trib_estaduais (str)
trib_municipais (str)
nbs (str)
info_complementar (str)
ibscbs (IBSCBS | None)
ibscbs_totals (IBSCBSTotals | None)
- Return type:
None
- class pynfse_nacional.pdf_generator.IBSCBSTotals¶
Bases:
objectParsed IBSCBS totalizer values from the response XML.
- __init__(v_tot_nf='', v_ibs_tot='', v_ibs_uf='', v_ibs_mun='', v_cbs='')¶
- Parameters:
v_tot_nf (str)
v_ibs_tot (str)
v_ibs_uf (str)
v_ibs_mun (str)
v_cbs (str)
- Return type:
None
- pynfse_nacional.pdf_generator.parse_nfse_xml(xml_content)¶
Parse NFSe XML and extract data for PDF generation.
- Parameters:
xml_content (str)
- Return type:
- pynfse_nacional.pdf_generator.generate_danfse_pdf(nfse_data, output_path=None, header_config=None)¶
Generate DANFSE PDF from NFSe data.
- Parameters:
nfse_data (NFSeData) – Parsed NFSe data
output_path (str | None) – Optional path to save PDF file
header_config (HeaderConfig | None) – Optional custom header configuration
- Returns:
PDF content as bytes
- Return type:
bytes
- pynfse_nacional.pdf_generator.generate_danfse_from_xml(xml_content, output_path=None, header_config=None)¶
Generate DANFSE PDF from NFSe XML content.
- Parameters:
xml_content (str) – NFSe XML string
output_path (str | None) – Optional path to save PDF file
header_config (HeaderConfig | None) – Optional custom header configuration
- Returns:
PDF content as bytes
- Return type:
bytes
- pynfse_nacional.pdf_generator.generate_danfse_from_base64(nfse_xml_gzip_b64, output_path=None, header_config=None)¶
Generate DANFSE PDF from base64-encoded gzipped NFSe XML.
- Parameters:
nfse_xml_gzip_b64 (str) – Base64-encoded gzipped NFSe XML (as returned by API)
output_path (str | None) – Optional path to save PDF file
header_config (HeaderConfig | None) – Optional custom header configuration
- Returns:
PDF content as bytes
- Return type:
bytes