1. Inicio
  2. Documentos
  3. NS CTe (English)
  4. CTe Utility Functions
  5. Generate PDF from processed XML

Generate PDF from processed XML

Through this method, it’s possible to generate and validate the CT-e data in XML previously processed by Sefaz and obtain the PDF file of the DACTE if no errors are found.

URL

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

Input data
FieldDescriptionOccurrenceData Type
X-AUTH-TOKENUser access token1-1String
projetoFill with: CTe or CTeOS1-1String
xmlXML of the CT-e previously processed by Sefaz1-1String
printCEANPrint EAN code.
Default value: False
0-1Boolean
obsCanhotoPrints infCpl field content, instead of "Recebemos de ..."0-1Boolean
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,
         "projeto":"CTe",
         "obsCanhoto": true
}'
\https://cte.ns.eti.br/util/generatepdf
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
pdfPDF of the CT-e in Base64Only when status = 200
Return examples

Successful return

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

Return with error

{
    "status": -2,
    "motivo": "CTe 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
200CT-e received and DACTE preview generated successfully
-2Error information according to the data type. Check the "motivo" field to identify the incorrect fields. The errors will be found in the "erros" object, which is an array of strings.
-3Non-existent validation schema for the CT-e version informed in the CTe/infCTe/versao
-4Data sent out of the expected pattern. Verify the "motivo" field for more information

Como podemos ajudar?