({ as = Format.PNG } = {})
| 159 | } |
| 160 | |
| 161 | function downloadThread({ as = Format.PNG } = {}) { |
| 162 | const elements = new Elements(); |
| 163 | elements.fixLocation(); |
| 164 | const pixelRatio = window.devicePixelRatio; |
| 165 | const minRatio = as === Format.PDF ? 2 : 2.5; |
| 166 | window.devicePixelRatio = Math.max(pixelRatio, minRatio); |
| 167 | |
| 168 | html2canvas(elements.thread, { |
| 169 | letterRendering: true, |
| 170 | }).then(async function (canvas) { |
| 171 | elements.restoreLocation(); |
| 172 | window.devicePixelRatio = pixelRatio; |
| 173 | const imgData = canvas.toDataURL("image/png"); |
| 174 | requestAnimationFrame(() => { |
| 175 | if (as === Format.PDF) { |
| 176 | return handlePdf(imgData, canvas, pixelRatio); |
| 177 | } else { |
| 178 | handleImg(imgData); |
| 179 | } |
| 180 | }); |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | async function handleImg(imgData) { |
| 185 | const binaryData = atob(imgData.split("base64,")[1]); |
no test coverage detected