Convert xlsx file to pdf
-
Hi. So because of large data we have to make template like xlsx file and we set unoconv to pdf. We want to get that file inside afterRender function and to append to main pdf . Problem here is that appendRes is xlsx file and have to be pdf . So we only need to convert xlsx file to pdf inside afterRender func. Does anyone know how to do this ?
This is rendering error :
Report "test_pdf" render failed.
Error when evaluating custom script /obrasci/deo6/test_script.js
Invalid PDF: startxref not foundasync function afterRender(req, res) { let $pdf = await jsreport.pdfUtils.parse(res.content, true) if ($pdf.pages[0] && $pdf.pages[0].text != null && $pdf.pages[0].text.includes('Main')) { const appendRes = await jsreport.render({ template: { shortid: 'Cvw4vfrtg'} }); res.content = await jsreport.pdfUtils.append(res.content, appendRes.content); } const coverRender = await jsreport.render({ template: { shortid: '_pCbjqGiD' } }) res.content = await jsreport.pdfUtils.prepend(res.content, coverRender.content) }
-
So this template renders xlsx?
const appendRes = await jsreport.render({ template: { shortid: 'Cvw4vfrtg'} });
And you want to run the unoconv to convert it to the pdf? Why don't you define the unoconv pdf conversion directly on the template properties?
If you need to configure unoconv dynamically, you can do it just like any other prop
const appendRes = await jsreport.render({ template: { shortid: 'Cvw4vfrtg', unoconv: { format: "pdf", enabled: true } } });