从服务器上我得到的pdf响应是字符串格式的,现在在客户端,我想把它转换成ArrayBuffer,这样我们就可以在pdf中再次更改了。在
我正在将其转换为pdf格式,如下所示,但不是pdf正在被破坏。
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint8Array(buf);
for (var i=0, strLen=str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
上面我从stackover flow得到的函数,我将Uint16Array更改为Uint8Array,pdfkit使用utf-8 uncode format。。在
^{pr2}$使用pdf工具包将其转换为字符串格式。在
add_str = render_to_string(address_template_path , {"address_dict": address_dict})
pdfkit.from_string(add_str, file_location)
address_pdf = open(file_location)
response = HttpResponse(address_pdf.read(), content_type='application/pdf') # Generates the response as pdf response.
response['Content-Disposition'] = 'inline;filename= %s' % envelope_id
目前没有回答
相关问题 更多 >
编程相关推荐