(imgData, canvas, pixelRatio)
| 193 | } |
| 194 | |
| 195 | async function handlePdf(imgData, canvas, pixelRatio) { |
| 196 | const { jsPDF } = window.jspdf; |
| 197 | const orientation = canvas.width > canvas.height ? "l" : "p"; |
| 198 | var pdf = new jsPDF(orientation, "pt", [ |
| 199 | canvas.width / pixelRatio, |
| 200 | canvas.height / pixelRatio, |
| 201 | ]); |
| 202 | var pdfWidth = pdf.internal.pageSize.getWidth(); |
| 203 | var pdfHeight = pdf.internal.pageSize.getHeight(); |
| 204 | pdf.addImage(imgData, "PNG", 0, 0, pdfWidth, pdfHeight, '', 'FAST'); |
| 205 | const { pathname, id, filename } = getName(); |
| 206 | const data = pdf.__private__.getArrayBuffer(pdf.__private__.buildDocument()); |
| 207 | await invoke('download', { name: `download/pdf/${id}.pdf`, blob: Array.from(new Uint8Array(data)) }); |
| 208 | await invoke('download_list', { pathname, filename, id, dir: 'download' }); |
| 209 | } |
| 210 | |
| 211 | function getName() { |
| 212 | const id = window.crypto.getRandomValues(new Uint32Array(1))[0].toString(36); |
no test coverage detected