1. Home
  2. NS NFe (English)
  3. Utility Functions
  4. Generate PDF from processed XML

Generate PDF from processed XML

Through this methid it’s possible to generate and validate the NF-e data in XML previously processed by Sefaz and obtain the DANFE PDF file if no error are found.

URL

Production: POST https://nfe.ns.eti.br/util/generatepdf

Input data
FieldOccurrenceData TypeDescription
X-AUTH-TOKEN1-1StringUser access token
xml1-1StringNF-e XML previously processed by Sefaz
printCEAN0-1BooleanPrint EAN code.
Default value: False
obsCanhoto0-1BooleanPrints infCpl field content, instead of "Recebemos de ..."
Request example

Generate PDF request

curl -X POST \
-H "Content-Type: application/json" \
-d '{"X-AUTH-TOKEN": "SEU_TOKEN","xml": "<?xml version=\"1.0\"encoding=\"utf-8\"?><nfeProc versao=\"4.00\"xmlns=\"http://www.portalfiscal.inf.br/nfe\"<NFe>..</NFe><protNFe versao=\"4.00\">...</protNFe></nfeProc>",
    "printCEAN": true,
    "obsCanhoto": true
}'\https: //nfe.ns.eti.br/util/generatepdf
Returned data
FieldDescriptionNotes
statusStatus processing code
motivoProcessing status literal description
pdfBase64 PDF from the NF-eOnly when status = 200
Return examples

Successful return

{
    "status": 200,
    "motivo": "PDF gerado com Sucesso!",
    "pdf": "JVBERi0xLjQKJeLjz..."
}

Return with error

{
    "status": -2,
    "motivo": "NFe invalido de acordo com a validacao contra schema",
    "erros": [
        "O campo 'vPIS' e de preenchimento obrigatorio e nao foi preenchido. Este campo deve ser informado antes do campo 'qBCProd' com numeros contendo no maximo 15 casas inteiras e 2 decimais. (cvc-complex-type.2.4.a: Invalid content was found starting with element 'qBCProd'. One of '{\"http://www.portalfiscal.inf.br/nfe\":vPIS}' is expected.)",
        "O campo 'vCOFINS' e de preenchimento obrigatorio e nao foi preenchido. Este campo deve ser informado antes do campo 'qBCProd' com numeros contendo no maximo 15 casas inteiras e 2 decimais. (cvc-complex-type.2.4.a: Invalid content was found starting with element 'qBCProd'. One of '{\"http://www.portalfiscal.inf.br/nfe\":vCOFINS}' is expected.)"
    ]
}
Return codes
CodeDescription
200NF-e received and DANFE preview generated successfully
-2Information error according to data type. Check the "movito" field to identify the incorrect fields. Errors will be found in the "erro" object, which is an array of strings
-3Non-existent validation schema for the NF-e version informed in NFe/infNFe/version
-4Data sent out of the expected pattern. Check the "motivo" for more information

How can we help?