Extension using LibreOffice to convert reports to the office-supported formats and to send the reports to the printers.
npm i @jsreport/jsreport-libreoffice
Install LibreOffice based on your OS.
libreoffice
properties and specify the desired output Format
, like pdf or specify the Printer
name where to send the output.Pdf Export options
. The documentation for the options can be found here.const jsreport = require('jsreport-proxy')
async function afterRender(req, res) {
const pdf = await jsreport.libreOffice.convert(res.content, 'pdf', {
pdfExportSelectPdfVersion: 15
})
res.content = pdf.content
}
const jsreport = require('jsreport-proxy')
async function afterRender(req, res) {
// send the report output to the default printer
await jsreport.libreOffice.print(res.content, 'default')
}
The soffice
binary is expected to be found in the default paths, however, you can also explicitly configure the binary path.
{
"extensions": {
"libreoffice": {
"sofficePath": "/soffice/path"
}
}
}