Skip to content

Instantly share code, notes, and snippets.

@cnp96
Created May 1, 2025 11:25
Show Gist options
  • Save cnp96/fd205b7b0d42f234522eb318f5ece66a to your computer and use it in GitHub Desktop.
Save cnp96/fd205b7b0d42f234522eb318f5ece66a to your computer and use it in GitHub Desktop.
Download from resume.io
let script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js";
script.onload = function() {
// Step 1: Select the canvas element
const canvas = document.querySelectorAll('canvas')[1]; // Adjust selector if needed
// Step 2: Convert canvas to image
const imgData = canvas.toDataURL('image/png');
// Step 3: Create PDF and add image
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: 'a4',
});
// Adjust dimensions to fit A4
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
// Calculate image size proportionally
const imgWidth = canvas.width;
const imgHeight = canvas.height;
const ratio = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
pdf.addImage(imgData, 'PNG', 0, 0, imgWidth * ratio, imgHeight * ratio);
pdf.save('Resume.pdf');
}
document.head.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment