0

How do I show a file from a binary string? to images files, it's possible to do by using atob() and then <img src="data:image/png;base64,... But to a PDF file for example, is there an equivalent? or some way that say to web browser ReadItAs("content-type:application/pdf", binaryPdf); I hope this is clear. Thanks in advance.

Update

I have tried this:

    var metatag = document.getElementsByTagName("meta")[0];

    metatag.setAttribute("http-equiv", "Content-type");
    metatag.setAttribute("content", "application/pdf");
    document.body.innerHTML = binaryString;

2 Answers 2

1

You can choose to render it directly through JS code, after you download the file with HttpRequest... People are making JS PDF readers for HTML5 - See here http://andreasgal.com/2011/06/15/pdf-js/

The other option is to embed it with an Iframe option

Sign up to request clarification or add additional context in comments.

Comments

0

are you trying to show a pdf file in browser, use iframe

<iframe id="abcdef" src="stargeturl" style="width: 100%; height: 800px;">
    Your browser does <em>not</em> support <code>iframe</code>
</iframe>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.