Hi all! Anyone knows if it is possible to render A...
# suitescript
d
Hi all! Anyone knows if it is possible to render AdvancedPDF/HTML template as html (not pdf)? (with N/render module)
w
Create a new template renderer, then set your template by ID and add a record/search for some example data. If you set a suitelet response with the renderToResponse method form your renderer you can see the XML version of your pdf.
👍 1
d
Currently I have the following to print as PDF:
Copy code
const renderer = render.create();

renderer.setTemplateByScriptId({scriptId: 'some_tempate_id'})
renderer.addCustomDataSource({
    format: render.DataSource.OBJECT,
    alias: "PDFLines",
    data: {lines: state.pdfLines},
});
context.response.addHeader({name: 'Content-Type:', value: 'application/pdf'})
context.response.addHeader({name: 'Content-Disposition', value: 'inline; filename="report.pdf"'})
context.response.writePage({pageObject: renderer.renderAsPdf(), })
Oh, renderToResponse, thank you, I'll try that
w
If you want control of the response headers you can use the renderAsString method.
d
Copy code
renderer.renderToResponse({response: context.response})
working as expected, thank you very much!
👍 2