Print document in ASP.NET Core PDF Viewer control
The PDF Viewer library allows you to print the PDF document programmatically using the print() method in the PrintModule.
The following steps are used to print the PDF document programmatically.
Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.
Step 2: Add the following code snippet to perform the print operation.
<button id="Print" onclick="Print()">Print</button>
<div style="width:100%;height:600px">
<ejs-pdfviewer id="pdfviewer"
style="height:600px"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
</ejs-pdfviewer>
</div>
<script>
function Print() {
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
pdfViewer.printModule.print();
}
</script><button id="Print" onclick="Print()">Print</button>
<div style="width:100%;height:600px">
<ejs-pdfviewer id="pdfviewer"
style="height:600px"
serviceUrl='/Index'
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
</ejs-pdfviewer>
</div>
<script>
function Print() {
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
pdfViewer.printModule.print();
}
</script>