Open DineshKumar-G opened 5 years ago
Code ? @DineshKumar-G
I have the same issue here. Here's my code that generates this:
let Pdf = new PdfDocument({
autoFirstPage: false,
layout: 'portrait',
size: 'A4',
info: {
Title: 'UID Freight Report'
}
})
let Table = new PdfTable(Pdf, {
topMargin: 0
})
Table
.addPlugin(new (PdfColumn)({
column: 'description'
}))
.addPlugin(new (PdfColumn)({
column: 'reference'
}))
.setColumnsDefaults({
headerBorder: 'B'
})
.addColumns([{
id: 'reference',
header: 'Reference',
align: 'left',
width: 100
}, {
id: 'description',
header: 'Description',
width: 200
}, {
id: 'locationName',
header: 'Location',
width: 50
}])
.onPageAdded((tb) => {
tb.addHeader()
})
Pdf.addPage()
let filter = request.input('filter', null)
if (filter) {
filter = JSON.parse(decodeURIComponent(filter))
let results = await SearchService.SearchLogs(filter, null, [], null, null, null, null)
Table.addBody(results.data)
}
response.type('application/pdf')
response.implicitEnd = false
Pdf.end()
Pdf.pipe(response.response)
This is part of an AdonisJS controller action