Pdf.js: Support needed for printing PDF

Created on 27 Nov 2018  路  2Comments  路  Source: mozilla/pdf.js

I have integrated pdfjslib to one of my website, its working fine as expected.
I am using the PDFViewer and code implemented for rendering pdf is as follows:
```
var container = angular.element('#container');
var pdfLinkService = new pdfjsViewer.PDFLinkService();
var pdfViewer = new pdfjsViewer.PDFViewer({
container: this.container[0],
linkService: this.pdfLinkService
});
this.pdfLinkService.setViewer(this.pdfViewer);

```
I have installed pdfjs through npm and I have pdfjs-dist directory for this lib and referring its pdf_viewer.js and pdf_viewer.css files + pdfjs.min.js and pdf-worker.min.js files.

I need to integrate print functionality to above code, as per my understanding pdfjs lib provides PDFPrintService for printing stuff and I also referred https://github.com/mozilla/pdf.js/issues/8766

In /node_modules/pdfjs-dist/web/pdf_viewer.js, I did not found any reference for PDFPrintService, its available at node_module/pdfjs-dist/lib/web,
How can I integrate and use this service in my application?

All 2 comments

The print service is only for the default viewer and it not exported for the components; refer to: https://github.com/mozilla/pdf.js/blob/f6bc93402ef35675ce61a278e3abe6b93d7fd393/web/pdf_viewer.component.js#L41-L58

In short, this is not in the pdfjs-dist library because it's primarily made for the default viewer. If need be you can use the code from the default viewer and implement it on top of your own viewer. If that works out, we can always consider to put it in the pdfjs-dist library, but for now that's not in scope, also given how limited the printing APIs are in browsers.

Please could someone leave a complete and clear example of its use, excuse me but I could not use the PDFPrintService

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jigskpatel picture jigskpatel  路  3Comments

smit-modi picture smit-modi  路  3Comments

BrennanDuffey picture BrennanDuffey  路  3Comments

SehyunPark picture SehyunPark  路  3Comments

xingxiaoyiyio picture xingxiaoyiyio  路  3Comments