多张图片转PDF
作者:互联网
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script> <script> const { jsPDF } = window.jspdf; var doc = new jsPDF(); var arr = ["1.png", "2.png", "3.png"]; for (let i = 0; i < arr.length; i++) { if (i > 0) { doc.addPage(); } doc.addImage(`imgs/${arr[i]}`, 'PNG', 0, 0); } doc.save("a4.pdf"); </script> </body> </html>
标签:jsPDF,arr,doc,addImage,var,PDF,png,图片 来源: https://www.cnblogs.com/ct568/p/14626727.html