在AngularJS中将base64字符串转换为PDF
如果文件大小超过10mb,我将无法在angular应用程序中以pdf格式打开base64字符串.浏览器崩溃并显示"AW,SNAP"页面. base64字符串(即"base64content")已经在开始时具有元数据,并且看起来像这样:
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
我正在通过以下方式在新标签页中以PDF格式打开base64字符串:
I am using below way to open the base64 string as a PDF in new tab:
$window.open(base64content);
发生这种情况是因为base64字符串太大,浏览器无法解释.这是因为pdf太重(超过2mb)是浏览器的最大限制.解决方案是使用基于斑点的方法.
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.