Free PDF Editor Online: 100% Free PDF Tools
Advanced PDF Editor Studio
1 / 1
|
100%
|
Create Digital Signature
`;
const blob = new Blob(['\ufeff' + htmlDoc], { type: 'application/msword' });
triggerDownload(URL.createObjectURL(blob), 'edited_document.doc');
}
else if (format === 'xlsx') {
let rows = [["Source", "Content / Extracted Text"]];canvas.getObjects('i-text').forEach(t => {
if (t.text && t.text.trim()) {
rows.push(["Custom Layer", t.text.trim()]);
}
});if (pdfDoc && activePages.length > 0) {
for (let idx of activePages) {
try {
const page = await pdfDoc.getPage(idx);
const textContent = await page.getTextContent();
let pageLines = [];
let currentLine = "";textContent.items.forEach(item => {
if (item.hasEOL) {
currentLine += " " + item.str;
if (currentLine.trim()) pageLines.push(currentLine.trim());
currentLine = "";
} else {
currentLine += " " + item.str;
}
});
if (currentLine.trim()) pageLines.push(currentLine.trim());pageLines.forEach(line => {
rows.push([`Page ${idx}`, line]);
});
} catch (err) {
console.error(err);
}
}
}let csvContent = rows.map(r => `"${r[0].replace(/"/g, '""')}","${r[1].replace(/"/g, '""')}"`).join("\r\n");
const csvBlob = new Blob(['\ufeff' + csvContent], { type: 'text/csv;charset=utf-8;' });
triggerDownload(URL.createObjectURL(csvBlob), 'extracted_data.csv');
}
}function triggerDownload(url, filename) {
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}