我们有一个多个PDF Base64字符串数组对象。将其转换为JavaScript或Jquery中的单个PDF文件
var base64String = "JVBERi0xLjcNCiWhs8XXDQoxIDAgb2JqDQo8PC9QYWdlcyAyIDAgUiAvVHlwZS9DYXRhbG9nPj4NCmVuZG9iag0KMiAwIG9iag0KPDwvQ291bnQgMS9LaWRzWyA0IDAgUiBdL1R5cGUvUGFnZXM+";
function openPDF() {
console.log('open pdf clicked');
window.open("data:application/octet-stream;base64," + base64String);
}
function openPDFv2() {
console.log('open pdf v2 clicked');
const container = document.querySelector('#container');
const tempLink = document.createElement('a');
tempLink.href = `data:application/pdf;base64,${base64String}`;
tempLink.setAttribute('download', 'my-fancy.pdf');
console.log('click now!', tempLink.click);
//container.append(tempLink);
tempLink.click();
}
字符串
其工作单Base64.
1条答案
按热度按时间zsbz8rwp1#
其完成的代码为多个PDF Base64转换为一个单一的PDF文件
**https://cdn.jsdelivr.net/npm/pdf-lib@1.11.0/dist/pdf-lib.min.js**在html文件中添加脚本:
字符串