youssef elhayani
youssef elhayani

Reputation: 745

Integrating PDFJS in Angular

I'm creating a new component in Angular to show PDF file , in order to that ,I used ng2-pdfjs-viewer following these steps in the link "https://www.npmjs.com/package/ng2-pdfjs-viewer" but it's not working. I don't know exactly where the problem. here the html component:

<ng2-pdfjs-viewer 
  #pdfViewer
 [pdfJsFolder]="'https://www.emse.fr/~picard/cours/1A/java/livretJava.pdf'"
  [externalWindow]="true"
  [downloadFileName]="'mytestfile.pdf'"
  [openFile]="false"
  [viewBookmark]="false"
  [download]="false">
 </ng2-pdfjs-viewer>

Can anyone explain where is the problem?

I have another Question is it possible to load pdf from an external link for example "D:\file.pdf".

Upvotes: 2

Views: 6148

Answers (1)

James
James

Reputation: 169

As per documentation of ng2-pdfjs-viewer(https://www.npmjs.com/package/ng2-pdfjs-viewer), [pdfJsFolder] is used to set path to PDF.JS's web and build folders.

You should use pdfSrc attribute to set pdf's path. It is mentioned under usage section of documentation

E.g.

<ng2-pdfjs-viewer pdfSrc="your pdf file path"></ng2-pdfjs-viewer>

The documentation also states that uses Mozilla's PDF.JS behind the scenes.
Irrespective of that, glad you got the issue resolved

Upvotes: 2

Related Questions