-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (19 loc) · 739 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (19 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
async function downloadImageAsPDF(imageUrl) {
try {
const response = await fetch(imageUrl);
if (!response.ok) throw new Error(`Image fetch failed! Status: ${response.status}`);
const blob = await response.blob();
const reader = new FileReader();
reader.onloadend = function () {
const imgData = reader.result;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.addImage(imgData, 'JPEG', 10, 10, 180, 250); // Adjust width & height as needed
doc.save("Resume_Template.pdf");
};
reader.readAsDataURL(blob);
} catch (error) {
console.error("Error:", error);
alert(error.message);
}
}