Copy source from custom laucheukhim jsPDF repository and just paste it to the Dev Console.
const { jsPDF } = window.jspdf;Inspired by tuhinpal drive-protected-pdf-downloader.js:
function generatePDF() {
console.log("Processing... Please wait while the PDF is being generated.");
const pdf = new jsPDF();
const images = document.querySelectorAll('img[src^="blob:"]');
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
let isFirstPage = true;
const imageStats = [];
for (const img of images) {
// Set canvas dimensions to the image dimensions
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0, img.width, img.height);
// Convert the canvas to image data
const imgData = canvas.toDataURL('image/jpeg', 1.0);
if (!isFirstPage) {
pdf.addPage();
}
isFirstPage = false;
// Add image data to the current PDF page
pdf.addImage(imgData, 'JPEG', 0, 0,
pdf.internal.pageSize.getWidth(),
pdf.internal.pageSize.getHeight());
// Collect image stats for console output
imageStats.push({
Index: imageStats.length + 1,
Width: img.width,
Height: img.height,
'Source URL': img.src
});
}
// Log stats using console.table
console.table(imageStats);
// Print summary statistics
console.log(`Total Images Processed: ${imageStats.length}`);
console.log(`Total Pages in the PDF: ${imageStats.length}`);
// Save the final PDF
pdf.save(`${document.title.replace(' - Google Drive', '')}.pdf`);
console.log("PDF generation completed successfully.");
}Zoom it to e.g. fit the window. The more You increase zoom – the more details (and size) final PDF will have.
generatePDF()🤩