4

Some PDF files won't render in Chrome browser but will render fine in Firefox. All files render fine in all browsers if emeded directly.

<object id="content-view" :data="content_view.base64" type="application/pdf"></object>

The confusing part is that the problem is only for some files and not all. Files are stored in a folder that is not public and that's why they are served as base64 for the user to view.

screenshot

I tested the problematic files by using online base64 decoders and I get the same result. Rendered in FF, not rendered in Chrome.

I cannot share any of the PDF files. They are all from the same source, scanned from the same device, PDF version 1.4, 4 pages.

I have tried:

  • using iframe, embed and object (same result)
  • unblocking Insecure content in Chrome site settings
  • opening and re-saving in Adobe Acrobat
  • using online PDF analyzers to see if any problems present (none found)
kopz
  • 656
  • 8
  • 18

2 Answers2

0

Rather than use the browsers native PDF renderer, you could use the JS one written by Mozilla.

ViewerJS provides a nice interface to this and if you want to embed it fullsize in a page, then you can place it in an iframe and control that with iFrame-resizer.

David Bradshaw
  • 11,100
  • 3
  • 37
  • 64
0

Instead of opening the PDF file in HTML object element, open it in a new window using Blob URL.

Please refer

Creating a BLOB from a Base64 string in JavaScript

to convert Base64 to Blob

Ajanyan Pradeep
  • 1,021
  • 1
  • 13
  • 25