WebViewer Version: 11.3
Do you have an issue with a specific file(s)?yes
Can you reproduce using one of our samples or online demos? no
Are you using the WebViewer server? yes
Does the issue only happen on certain browsers? no
Is your issue related to a front-end framework? yes
Is your issue related to annotations?no
Please give a brief summary of your issue:
(Think of this as an email subject)
While creating the desktop version the viewer is not showing. while i copied all the sample code. sample code is working but the project what i created is not having that viewer. In the devtools the error coming as
Uncaught ReferenceError: require is not defined
- at render.js:5:20*
const { dialog } = require(âelectronâ).remote;
const fs = require(âfsâ);
const viewerElement = document.getElementById(âviewerâ);
const openFileBtn = document.getElementById(âopenâ);
const saveFileBtn = document.getElementById(âsaveâ);
WebViewer(
{
path: ââŠ/public/lib/webviewerâ, // Path to WebViewer lib folder
licenseKey:âdemo:17425483407ba70bbecd6084ef03160789â,
initialDoc: ââŠ/public/files/CADMATE FIRE SERVICE-SPRINKLER.pdfâ,
useWebComponent: false,
},viewerElement
).then((instance) => {
// Interact with APIs here.
// See Guides for JavaScript PDF Viewer Library | Apryse documentation for more info
instance.UI.setTheme(âdarkâ);
instance.UI.disableElements([âdownloadButtonâ]);
const { documentViewer, annotationManager } = instance.Core;
openFileBtn.onclick = async () => {
const file = await dialog.showOpenDialog({
properties: ["openFile", "multiSelections"],
filters: [
{ name: "Documents", extensions: ["pdf", "docx", "pptx", "xlsx"] },
{ name: "Images", extensions: ["png", "jpg"] },
],
});
if (!file.canceled) {
instance.UI.loadDocument(file.filePaths[0]);
}
};
saveFileBtn.onclick = async () => {
const file = await dialog.showOpenDialog({
title: "Select where you want to save the PDF",
buttonLabel: "Save",
filters: [
{
name: "PDF",
extensions: ["pdf"],
},
],
properties: ["openDirectory"],
});
if (!file.canceled) {
const doc = documentViewer.getDocument();
const xfdfString = await annotationManager.exportAnnotations();
const data = await doc.getFileData({
// saves the document with annotations in it
xfdfString,
});
const arr = new Uint8Array(data);
fs.writeFile(
`${file.filePaths[0].toString()}/annotated.pdf`,
arr,
function (err) {
if (err) throw err;
console.log("Saved!");
}
);
}
};
});
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
Please provide a link to a minimal sample where the issue is reproducible: