javascript - 使用 javascript 将字节转换为 PDF
问题描述
我有一个 WSDL,它向我发送字节格式的 PDF,我想用 javascript 在新窗口中打开这个 PDF。问题是我无法将编码字节转换为 PDF。我尝试了这段代码,但它不起作用我不知道是不是因为我的 PDF 中有一张图片和一些行,或者这个版本适用于旧版浏览器。
var getReleveDoc = function(i) {
var datas = {
'service': 'relevePrest',
'i': $('#idNumPersonne').val(),
'n': $('#numRlv_td' + i).text(),
'b': $('#numBatch_td' + i).text(),
'e': $('#codeEntite').val()
};
$.get('./download',
datas,
function(data) {
if (data.security) {
location.reload();
} else if (data.erreur) {
erreur(data.erreur);
} else {
var blob = new Blob([data], {
type: "application/pdf"
});
var link = window.URL.createObjectURL(blob);
window.open(link, '', 'height=650,width=840');
}
ready();
});
};
这是我生成的字节的一小部分
1.4
%����
1 0 obj
<<
/Keywords ()
/Creator (BdocPDF V5.3)
/Producer (Apache FOP Version svn-trunk)
/CreationDate (D:20200120134322+00'00')
>>
endobj
2 0 obj
<<
/N 3
/Length 3 0 R
/Filter /FlateDecode
>>
stream
x���wTS��Ͻ7�P����khRH
�H�.*1 J�� "6DTpDQ��2(���C��"��Q��D�qp�Id�y�͛��~k����g�}ֺ ����LX ��X��ň��g`� l �p��B�F�|،l���� ��*�?�� ����Y"1 P������\�8=W�%�Oɘ�4M�0J�"Y�2V�s�,[|��e9�2�<�s��e���'��9���`���2�&c�tI�@�o��|N6 (��.�sSdl-c�(2�-�y �H�_��/X������Z.$��&\S�������M����07�#�1ؙY�r f��Yym�";�8980m-m�(�]����v�^��D���W~�
解决方案
推荐阅读
- nasm - 只有在未定义的情况下(到目前为止),如何在 nasm 中定义符号?
- javascript - 为什么使用 jquery 后 Colspan 不起作用?
- linux - cmake fixup_bundle 没有说明失败的原因
- python - 在 Pandas 中将 Months 列添加到 Date 列
- asp.net-core - 如何强制用户登录 Asp.Net Core 3.1 Swagger UI 页面
- django - AJAX 请求的 Django 模型翻译
- amazon-web-services - 使用带有 lambda 的自定义资源以 cloudformation 导出输出
- arrays - 遍历 char 数组以查找数值时出错
- javascript - 为什么我无法访问 html 中的 Table 容器?
- html - 拉伸垂直flexbox的内部内容