Skip to content

credimi/digital-invoice-to-pdf

Repository files navigation

This module generates a PDF stream from a 🇮🇹 Digital invoice XML string input

TLDR

from HERE to THERE

Example inside your express request

  request.get(fileUri, async (error, response, body) => {
    if (error) return 'Remember to manage Errors'

    try {
      const result = await xmlToPDF(body)
      try {
        // RES
        res.set('Content-Type', 'application/pdf')
        result.pipe(res)
      } catch (e) {
        console.log(`Error occurred while rendering: ${e}`)
        res.status(500).end()
      }
    } catch (error) {
      logger.error(error)
      res.status(500)
      res.send({ error: 'Failed to parse XML', message: error.message })
    }
  })
}

The module exports also:

a simple xmlToJson function that uses XML2JS and returns a typed JSON (check the types DigitalInvoiceJson in types folder)

the function xmlToCompactJson that transform the previous DigitalInvoiceJson in a more consistent and smaller DigitalInvoice (check the types DigitalInvoice in types folder)

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors