How to Print the PDF in JavaScript (ES6) PDF Viewer

14 Aug 20261 minute to read

Print a PDF document programmatically using the [print] (https://ej2.syncfusion.com/documentation/api/pdfviewer/#print) method in the Print module.

The following steps are used to print the PDF document programmatically.

Step 1: Follow the steps in the Get started with JavaScript ES6 PDF Viewer guide to create a sample.

Step 2: Add the following code snippet to perform the print operation.

<button id="print">Print</button>
document.getElementById('print').addEventListener('click', ()=> {
   //Print the loaded document.
   viewer.printModule.print();
});

Find the sample: Print the PDF document programmatically