PDF to HTML
Convert PDF text content into an HTML document.
\\n\\n';
for(let i = 1; i <= pdf.numPages; i++) {
status.textContent = `Extracting page ${i} of ${pdf.numPages}...`;
const page = await pdf.getPage(i);
const textContent = await page.getTextContent();
htmlOutput += `\\n`;
let lastY = -1;
for (let item of textContent.items) {
if (lastY !== item.transform[5] && lastY !== -1) {
htmlOutput += '
\\n';
}
htmlOutput += `${item.str}`;
lastY = item.transform[5];
}
htmlOutput += '\\n
\\n
\\n';
}
htmlOutput += '
\\n