I need to print a report by saving it as an HTML template and then printing it. However, I don't want the "Save As" window to pop up—only the print window should appear, using the HTML template as the content to print. Additionally, I need an alert to notify users when the table does not fit properly due to a large number of columns.
Hello Ramcy,
Thank you for reaching out to us.
To print a report generated in the HTML, you can set the type parameter of the exportTo()
method to "html"
and use destinationType: "plain"
. For example:
const params = {
destinationType: "plain",
}
pivot.exportTo("html", params, (html) => {
const printWindow = window.open("", "_blank")
printWindow.document.open()
printWindow.document.write(html.data)
printWindow.document.close()
printWindow.print()
})
Please check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/u1a8mkfh/
Regarding the alert to notify users when the table does not fully fit, Flexmonster does not support calculating if columns fit into the print layout. Alternatively, you can use our built-in print
function that splits columns into multiple pages if the table needs more space. You are welcome to find more details in our documentation: https://www.flexmonster.com/doc/print-report/
Please let us know if it works for you. Looking forward to hearing from you.
Kind regards,
Nadia