%PDF-1.4 %Óëéá 1 0 obj <> endobj 3 0 obj <> endobj 4 0 obj <
| Server IP : 212.252.79.165 / Your IP : 216.73.217.172 [ Web Server : Apache System : Linux 212-252-79-165.cprapid.com 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 User : cehaburo ( 1001) PHP Version : 8.1.33 Disable Function : exec,passthru,shell_exec,system Domains : 48 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/cehaburo/www/pdfjs/samples/advanced/table-extraction/ |
Upload File : |
// @link WebViewerInstance: https://www.pdftron.com/api/web/WebViewerInstance.html
// @link UI.loadDocument: https://www.pdftron.com/api/web/UI.html#loadDocument__anchor
WebViewer(
{
path: '../../../lib',
initialDoc: '../../files/table.pdf',
},
document.getElementById('viewer')
).then(instance => {
samplesSetup(instance);
const { annotManager, docViewer } = instance;
docViewer.on('documentLoaded', async () => {
const doc = docViewer.getDocument();
const data = await doc.getFileData();
const fileName = doc.getFilename();
const arr = new Uint8Array(data);
const file = new File([arr], fileName, { type: 'application/pdf' });
const { xfdf } = await extractTableData(file);
annotManager.importAnnotations(xfdf);
});
document.getElementById('file-picker').onchange = async e => {
const file = e.target.files[0];
if (file) {
docViewer.loadDocument(file);
}
};
async function extractTableData(file) {
const response = await fetch('https://ai-serve.pdftron.com/extract/predict', {
method: 'POST',
body: file,
headers: {
'File-Name': file.name || 'test_pdf.pdf',
'Content-Type': 'application/json',
},
});
const data = await response.json();
const { xfdf, html } = data;
return { xfdf, html };
}
});