Print Modes in Our JavaScript PDF Viewer
To print a document with PSPDFKit for Web, you can choose between two printing modes, each with its own tradeoffs.
The available modes are:
-
PSPDFKit.PrintMode.DOM
-
PSPDFKit.PrintMode.EXPORT_PDF
It’s possible to configure the printMode
via the initial configuration:
PSPDFKit.load({ printMode: PSPDFKit.PrintMode.EXPORT_PDF });
It’s also possible to enforce a print mode when printing programmatically via the API:
instance.print({ mode: PSPDFKit.PrintMode.EXPORT_PDF });
PSPDFKit.PrintMode.DOM
PSPDFKit.PrintMode.DOM
is the default printing mode because of its reliability and cross-browser support. This method renders all pages of a PDF document as images before sending them to the printer. The advantages of this mode are that it’s supported by all major browsers and it doesn’t give your users access to the source PDF file. However, it’s resource-intensive, and printing large PDF files with this mode may crash the browser.
When printing with PSPDFKit.PrintMode.DOM
, you might get a warning message about incorrect printing results due to pages with different sizes. The reason for this warning is that this printing mode renders each page as an image at a specified DPI (dots per inch) before sending it to the printer. Because the original pages may have different dimensions, converting them to images with a fixed scale can lead to discrepancies in how the content is displayed and printed. This can result in inconsistencies in the visual appearance and quality of the printed output. To mitigate this issue, use PSPDFKit.PrintMode.EXPORT_PDF
as explained below.
PSPDFKit.PrintMode.EXPORT_PDF
This method is resource efficient and lets you avoid having to render every page in advance, which could balloon memory usage to multiple GBs on PDFs with more than 100 pages.
Google Chrome and Microsoft Internet Explorer provide the APIs required to use the native renderer; meanwhile, as a fallback on other browsers, we generate and open a PDF in a new tab. This allows users to print the PDF in a native PDF reader which can, in contrast to browser-built implementations, talk directly to the connected printer. A drawback of this approach is that it might give users access to the source files.
Below is an overview of all supported browsers and their behaviors.
-
Google Chrome: This browser is fully supported. Printing a PDF page will use the native renderer that’s part of the Chrome browser.
-
Internet Explorer 11: This browser is partially supported. To support printing, the Windows Media Feature Pack must be installed, which is the case on 99 percent of all Windows installations, unless you use the N or KN editions. If the Windows Media Feature Pack is installed, the browser will ask you to install the Adobe Reader PDF extension upon first use. With this extension enabled, printing works as expected and without opening a new tab.
Internet Explorer 11 is no longer supported in our Web SDK as of version 2022.5. Edge 18 is no longer supported in our Web SDK as of version 2023.2.
-
Microsoft Edge: This browser opens a new tab and uses the built-in WinRT PDF Renderer (Windows.Data.Pdf) library. Edge no longer supports ActiveX and thus doesn’t support third-party plugins such as Adobe Reader.
-
Apple Safari: This browser opens a new tab which loads either Apple’s Preview PDF renderer or the Adobe Reader plugin, if installed.
-
Mozilla Firefox: This browser opens a new tab, which renders the PDF via Mozilla’s JavaScript PDF renderer, albeit slowly.
Check out our API Reference for more information.