WhatsApp Group Join Now

પરિમિતિ અને ક્ષેત્રફળ

📐 પરિમિતિ-ક્ષેત્રફળ ક્વિઝ

✔ સાચો જવાબ: ${it.correct} ✎ પસંદ કર્યું: ${it.selected || '---'}
`; }).join(""); c.innerHTML = metaTop + `
    ${list}
`; // Typeset Math, wait for fonts, then rasterize compactly if (window.MathJax && window.MathJax.typesetPromise) { await MathJax.typesetPromise([c]); } await document.fonts.ready; const canvas = await html2canvas(c,{scale:2,backgroundColor:'#ffffff', windowWidth:800}); const { jsPDF } = window.jspdf; const pdf = new jsPDF('p','mm','a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidthPx = canvas.width; const imgHeightPx = canvas.height; const pxPerMm = imgWidthPx / pdfWidth; const pageHeightPx = Math.floor(pdfHeight * pxPerMm); let position = 0, pageCount=0; while(position < imgHeightPx){ const sliceHeight = Math.min(pageHeightPx, imgHeightPx - position); const pageCanvas = document.createElement('canvas'); pageCanvas.width = imgWidthPx; pageCanvas.height = sliceHeight; const ctx = pageCanvas.getContext('2d'); ctx.fillStyle="#fff"; ctx.fillRect(0,0,pageCanvas.width,pageCanvas.height); ctx.drawImage(canvas,0,position,imgWidthPx,sliceHeight,0,0,pageCanvas.width,pageCanvas.height); const imgData = pageCanvas.toDataURL('image/png',1.0); const imgHeightMm = pageCanvas.height / pxPerMm; if(pageCount>0) pdf.addPage(); pdf.addImage(imgData,'PNG',0,0,pdfWidth,imgHeightMm); position += sliceHeight; pageCount++; } pdf.save(`QuizReport_${quizData.code}_${studentCode}.pdf`); } })();

Leave a comment