MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / handlePdf

Function handlePdf

ChatGPT/src-tauri/src/scripts/export.js:195–209  ·  view source on GitHub ↗
(imgData, canvas, pixelRatio)

Source from the content-addressed store, hash-verified

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);

Callers 1

downloadThreadFunction · 0.85

Calls 2

getNameFunction · 0.85
invokeFunction · 0.85

Tested by

no test coverage detected