Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
{
“UI version”: “8.7.0”,
“Core version”: “8.7.4”,
“webviewer.min.js”: “8.7.4”,
“Build”: “Ni8xNi8yMDIzfDhhZjQyYTgwOTU=”,
“WebViewer Server”: false,
“Full API”: false
}
Detailed description of issue
I have a chrome extension in an iframe, and I want to load the pdf viewer in sidebar
We render react app in a extension which is a sidebar basically
The issue is, how can i set up license key which would support this behavior? I tried with chrome-extension//unique id it did not work, how can i overcome this issue?
Expected behaviour
A user can view pdf in sidebar at any given moment at any website.
Does your issue happen with every document, or just one?
We have a web app as well it works in fine there but we need this to integrate with our extension as well
Link to document
{Provide a link to the document in question if possible}
Code snippet
export const PDFViewer = ({url, name, size}: IPDFViewer) => {
const viewer = useRef(null);
useEffect(() => {
const initializeWebViewer = async (blob: Blob) => {
try {
const instance = await WebViewer(
{
path: '/',
licenseKey: 'license-key',
},
viewer.current
);
blob &&
(await instance.UI.loadDocument(blob, {
filename: name,
}));
instance.setLayoutMode(instance.LayoutMode.Single);
// stops inline executing of js
instance.Core.disableEmbeddedJavaScript();
} catch (e) {
logging.capture(e);
}
};
const loadPdf = async () => {
const file = await fetchAsset(url);
initializeWebViewer(file);
};
loadPdf();
}, [url]);
return <Box ref={viewer} {...sizes[size]} w='100%' flexShrink={0} />;
};