ngx-extended-pdf-viewer: Cannot display file offline on iOS

Hi, I am not sure this is actually a bug caused by this library (which is very cool and well documented, thank you!), however I have been struggling to find a solution to this problem and I hope that somebody could give me some suggestions.

I’m encountering a weird error when trying to load a Blob saved locally (temporary stored in IndexedDB) while offline (no internet connection). The application I am working on uses heavily the Service Worker to load the app offline and serve some features, including a PDF viewer. I have followed all the setup and the library works:

  • online in any browser and device;
  • offline on desktop browsers (Chrome and Safari) and on mobile Android devices (Chrome).

The lib component is configured like this in the html template:

<ngx-extended-pdf-viewer
  [src]="file" useBrowserLocale="true" height="85vh"
  [textLayer]="true" [showPresentationModeButton]="true"
  [enablePinchOnMobile]="true" [enablePrint]="false"
  [showBookmarkButton]="false" [showDownloadButton]="false"
  [showOpenFileButton]="false" [showPrintButton]="false"
></ngx-extended-pdf-viewer>

where file is a Blob saved in IndexedDB and passed to the component.

The final error showed in the pdf viewer is: PDF.js v2.7.667 (build: 162577ae4) Message: The PDF file is empty, i.e. its size is zero bytes However, the problem is not that there is no file, but it looks like that there is a network related issue that blocks the operation. Looking in the Network tab of the developer tools, it looks like the library tries to get something from the same application domain and fails (504) since there is no internet connection. Nonetheless, on desktop and Android it manage to continue its operations, download from cache the PDF.js file and shows the PDF file correctly. The same operation on iOS get blocked and shows the error in the viewer.

Version info

  • 8.0.0-beta.8

Smartphone:

  • iPhone 11 - iOS 14.4 - Safari (14.0.3 Mobile)

Demo PDF file Any PDF as the same issue.

Additional context I have previously tried out the ng2-pdfjs-viewer library but there I encounter a slightly different issue, which you can find in the related issue tracker. I though that, since that library uses an iframe, it could be some CORS/Security issue.

Finally, I added an issue directly in PDF.js issue tracker but with no luck (the issue was the one from the ng2-pdfjs-viewer library): https://github.com/mozilla/pdf.js/issues/12967#issue-802927639

As a side note, on iOS the Presentation Mode Button does not show up…!

As I said at the beginning, any help would be much appreciated! Thanks again for your nice work!

Screenshots You can find some screenshot of Android and iOS tests:

Android ngx-pdf-viewer_android_01

ngx-pdf-viewer_android_01_headers

ngx-pdf-viewer_android_01_initiators

ngx-pdf-viewer_android_02

iOS ngx-pdf-viewer_iOS_01

ngx-pdf-viewer_iOS_02

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (26 by maintainers)

Most upvoted comments

I have taken a look at #534 and it seems strange that in this case there is actually the blob:http request (as seen in the developer tools)…

I still wasn’t able to check the logs using the base64, I hope to be able to do it next week. For sure we could add some documentation details on this, however I would like to prepare a repo or something to test more thoroughly this issue directly on PDF.js. I will try to find some time…!

Oh, I just saw you’ve translated the Italian screenshot to English. That’s very kind of you. But I don’t think that’s necessary. I’m sort of proficient at Spanish, and I’ve learned Latin at school, so I can usually decipher Italian texts. Of course, I’ll miss all the fine points, but as long as we’re talking about tech, my approach usually does the trick. Although I have to admit I’d never guessed that “indirizzio web” means “web address”. 😃

However, actual speech is a completely different story: I always think I understand what’s going on, but in reality, I understand nothing…

I’ll check the it translation and for sure will contribute to it! A beer will be just perfect, but I will probably be the one buying if we manage to solve this mess ^_^

May your cold be gone soon! 💪