0

So here is what I am trying to do. I am getting raw pdf data from a wb service. The data looks something like this.

enter image description here

I get this data in the $http.success() in a string format. I wanted to show this data using the PDF.js library in my angular/ionic code. Is there any way to correct supply this pdf string data as input for the PDF.js library

I also found this angular directive that eases my use of PDF.js in angular code. https://github.com/akrennmair/ng-pdfviewer

I also tried to use this enhancement as a way to specify the data URI's as input. But I couldn't find a good way of converting my input to data URI format (base 64 encoding). https://github.com/akrennmair/ng-pdfviewer/pull/15

Any help on this will be highly appreciated. Please provide explanation with code if possible.

grane2212
  • 764
  • 1
  • 10
  • 29
  • 2
    raw data is good for PDF.js (data URI is not so much). however transmitted via web/XHR a string might loose data, it will be better if you will get arraybuffer/uint8array from your web service. PDFJS.getDocument({data: rawPdfData}) shall work in your case – async5 Oct 23 '15 at 12:33
  • https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#can-i-specify-a-different-pdf-in-the-default-viewer – async5 Oct 23 '15 at 12:52
  • @async5 It worked like a charm. – grane2212 Oct 23 '15 at 20:59
  • I have the same issue as above. when supplying the data after converting it to uint8array I get a console error Invalid PDF structure from pdf.js – patz Feb 02 '16 at 18:40
  • StackOverflow answer http://stackoverflow.com/questions/12092633/pdf-js-rendering-a-pdf-file-using-a-base64-file-source-instead-of-url explains just that. – Carlo Bonamico Sep 17 '16 at 09:21

0 Answers0