I am using “@pdftron/webviewer”: “^11.1.0”, with reactjs.
my code is like this
useEffect(() => {
webViewerInstance.UI.loadDocument(templateUrl, {
officeOptions: {
doTemplatePrep: true,
},
onError: (err) => {
console.log(err)
}
});
},[templateUrl, webViewerInstance, templateRendered])
useEffect(() => {
WebViewer(
{
path: '/pdftron/webviewer',
licenseKey: 'MYKEY',
preloadWorker: 'office',
isReadOnly: true,
disabledElements: [
'default-top-header',
'tools-header'
]
},
viewer.current!,
).then((instance) => {
setWebViewerInstance(instance)
instance.Core.documentViewer.addEventListener('documentLoaded', async () => {
const doc = instance.Core.documentViewer.getDocument();
console.log("Document type:", doc.getType());
try {
const templateKeys = await doc.getTemplateKeys('schema') as TemplateSchema;
console.log("Extracted Template Keys:", templateKeys);
const schema = buildSchema(templateKeys.keys);
onSchemaLoaded(schema as IntegrationSchema);
} catch (err) {
console.error("Error extracting template keys:", err);
setRenderingError("Failed to extract template keys.");
}
});
});
}, [onSchemaLoaded, uploadInProgress, uploadCompleted, webViewerInstance]);
It works file with docx and pptx file but not working with xlsx file.
Attached here my xlsx file
simple xls.xlsx (4.8 KB)