adonis-pdf
Service provider for building PDFs using pdfmake.
Installation
- Run
npm i adonis-pdf
or yarn add adonis-pdf
- Create
config/pdf.js
and set any custom fonts you wish to use:
module.exports = {
fontDescriptors: {
}
}
- Add
'adonis-pdf/providers/PdfProvider'
to the providers
array within start/app.js
Usage
'use strict'
const Pdf = use('Pdf')
class MyController {
async generatePdf ({ response }) {
const pdf = new PDF({
})
const doc = Pdf.create({
content: [
{ text: 'test' }
]
})
doc.pipe(response.response)
doc.end()
return response
}
}