1

I am unable to open a base64 string as pdf in angular application if the file size is more than say 10mb. The browser crashes with a page saying "AW, SNAP". The base64 string i.e. "base64content" already has the metadata at the start and looks something like this:

data:application/pdf;base64,JVBERi0xLjQK...DUKJSVFT0YK

I am using below way to open the base64 string as a PDF in new tab:

$window.open(base64content);

2 Answers 2

6

Try with

window.open('data:application/pdf;base64,' + base64content);
Sign up to request clarification or add additional context in comments.

1 Comment

My base 64 string already has this metadata at the start. It looks like this: data:application/pdf;base64,JVSSSRi0xLjQKJeLjz9MKMSAwIG9iago8PC9EZWNvZGVQYXJ…dlMDVlYTITTTTT533ECctfgNTQzYWFjOSSSTMwMTRiM2RhZDk5Pl0+PgpzdGFydHhyZWYKNjk1ODUKJSVFT0YK
0

This happened because the base64 string was too big for the browser to interpret. This is because the pdf was heavy(more than 2mb) the approx max limit of browser. The solution was to use blob based approach.

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.