|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Print Overview in TypeScript PDF Viewer | Syncfusion |
| 4 | +description: Learn how to enable, monitor and customize printing in the Syncfusion TypeScript PDF Viewer component. |
| 5 | +platform: document-processing |
| 6 | +control: Print |
| 7 | +documentation: ug |
| 8 | +domainurl: ##DomainURL## |
| 9 | +--- |
| 10 | + |
| 11 | +# Print Overview in TypeScript PDF Viewer Control |
| 12 | + |
| 13 | +The TypeScript PDF Viewer includes built‑in printing via the toolbar and APIs so you can control how documents are printed and monitor the process. |
| 14 | + |
| 15 | +Select **Print** in the built-in toolbar to open the browser print dialog. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +## Enable or Disable Print in TypeScript PDF Viewer |
| 20 | + |
| 21 | +The Syncfusion TypeScript PDF Viewer component lets users print a loaded PDF document through the built-in toolbar or programmatic calls. Control whether printing is available by setting the `enablePrint` property. |
| 22 | + |
| 23 | +The following TypeScript examples render the PDF Viewer with printing enabled in standalone and server-backed applications. |
| 24 | + |
| 25 | +{% tabs %} |
| 26 | +{% highlight ts tabtitle="Standalone" %} |
| 27 | + |
| 28 | +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection} from '@syncfusion/ej2-pdfviewer'; |
| 29 | + |
| 30 | +PdfViewer.Inject(Toolbar,Magnification,Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection); |
| 31 | + |
| 32 | +let pdfviewer: PdfViewer = new PdfViewer({enablePrint: true, documentPath:'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',resourceUrl: "https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib"}); |
| 33 | +pdfviewer.appendTo('#PdfViewer'); |
| 34 | + |
| 35 | +{% endhighlight %} |
| 36 | +{% highlight ts tabtitle="Server-Backed" %} |
| 37 | + |
| 38 | +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection} from '@syncfusion/ej2-pdfviewer'; |
| 39 | + |
| 40 | +PdfViewer.Inject(Toolbar,Magnification,Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection); |
| 41 | + |
| 42 | +let pdfviewer: PdfViewer = new PdfViewer({enablePrint: true, documentPath:'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',serviceUrl: 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'}); |
| 43 | +pdfviewer.appendTo('#PdfViewer'); |
| 44 | + |
| 45 | +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection} from '@syncfusion/ej2-pdfviewer'; |
| 46 | + |
| 47 | +PdfViewer.Inject(Toolbar,Magnification,Navigation, Annotation, LinkAnnotation,ThumbnailView,BookmarkView, TextSelection); |
| 48 | + |
| 49 | +let pdfviewer: PdfViewer = new PdfViewer({enablePrint: true, documentPath:'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'}); |
| 50 | + |
| 51 | +pdfviewer.appendTo('#PdfViewer'); |
| 52 | + |
| 53 | +{% endhighlight %} |
| 54 | +{% endtabs %} |
| 55 | + |
| 56 | +## Print programmatically in Typescript PDF Viewer |
| 57 | + |
| 58 | +To start printing from code, call the `print.print()` method after loading a document. This approach is useful when you need to wire up custom UI or initiate printing automatically. |
| 59 | + |
| 60 | +```html |
| 61 | +<button id="print">Print PDF</button> |
| 62 | +``` |
| 63 | + |
| 64 | +{% tabs %} |
| 65 | +{% highlight ts tabtitle="Standalone" %} |
| 66 | + |
| 67 | +import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageInfoModel } from '@syncfusion/ej2-pdfviewer'; |
| 68 | + |
| 69 | +// Inject required modules |
| 70 | +PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields); |
| 71 | + |
| 72 | +const pdfviewer: PdfViewer = new PdfViewer({ |
| 73 | + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', |
| 74 | + resourceUrl: "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib" |
| 75 | +}); |
| 76 | +pdfviewer.appendTo('#PdfViewer'); |
| 77 | +//print on button click |
| 78 | +const printButton = document.getElementById('print'); |
| 79 | +if (printButton) { |
| 80 | + printButton.onclick = function () { |
| 81 | + pdfviewer.print.print(); |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +{% endhighlight %} |
| 86 | +{% highlight ts tabtitle="Server-Backed" %} |
| 87 | + |
| 88 | +import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageInfoModel } from '@syncfusion/ej2-pdfviewer'; |
| 89 | + |
| 90 | +// Inject required modules |
| 91 | +PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields); |
| 92 | + |
| 93 | +const pdfviewer: PdfViewer = new PdfViewer({ |
| 94 | + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', |
| 95 | + serviceUrl: 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/' |
| 96 | +}); |
| 97 | +pdfviewer.appendTo('#PdfViewer'); |
| 98 | +//print on button click |
| 99 | +const printButton = document.getElementById('print'); |
| 100 | +if (printButton) { |
| 101 | + printButton.onclick = function () { |
| 102 | + pdfviewer.print.print(); |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +{% endhighlight %} |
| 107 | +{% endtabs %} |
| 108 | + |
| 109 | +## Key capabilities: |
| 110 | + |
| 111 | +- Enable or disable printing with the enablePrint property |
| 112 | +- Start printing from UI (toolbar Print) or programmatically using print.print() |
| 113 | +- Control output quality with the printScaleFactor property (0.5–5) |
| 114 | +- Auto‑rotate pages during print using enablePrintRotation |
| 115 | +- Choose where printing happens with printMode (Default or NewWindow) |
| 116 | +- Track the life cycle with printStart and printEnd events |
| 117 | + |
| 118 | +[View Sample in GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples) |
| 119 | + |
| 120 | +## See Also |
| 121 | + |
| 122 | +- [Print quality](./print-quality) |
| 123 | +- [Enable print rotation](./enable-print-rotation) |
| 124 | +- [Print modes](./print-modes) |
| 125 | +- [Print events](./events) |
0 commit comments