4

I have this screenshot displaying a PDF in an iframe on Chrome for Android. My device is Samsung Galaxy S9+.

iframe screenshot

When I click on the open button, nothing happens.

I've also opened the same page in the default Samsung Browser and the PDF begins to download immediately.

Does anybody know what is going on with this PDF on Google Chrome?

1

1 Answer 1

1

For anyone looking for more information on this topic, I never figured out a way to display the pdf in an iframe. Instead, I setup a download link to an html element to allow the pdf to be viewed outside of the browser.

I first had to convert the raw data to an object URL like so:

const byteArray = new Uint8Array(atob(rawPdfData).split('').map(char => char.charCodeAt(0)));
const pdf = new Blob([byteArray], { type: 'application/pdf' });
const pdfUrl = URL.createObjectURL(pdf);

After this, it was simple enough to create a download link:

const pdfDownload = document.getElementById('pdfDownload');
(pdfDownload as HTMLAnchorElement).href = pdfUrl;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .