在AngularJS中将base64字符串转换为PDF [英] Convert base64 string to PDF in AngularJS

查看:443
本文介绍了在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.

这篇关于在AngularJS中将base64字符串转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆