WebViewer Version: 6.14.16
I am trying to view PDF files in the WebViewer from an API service in a React application. Here is a copy of my code
if (viewerInstance){
viewerInstance.UI.loadDocument(props.fileData.filePath, {extension: 'pdf'})
}else{
WebViewer({
path: 'lib/pdftron',
initialDoc: props.fileData.filePath,
extension: 'pdf'
}, viewerDiv.current as HTMLDivElement).then(instance => {
setViewerInstance(instance);
});
}
When I initially create the WebViewer, it works fine. But when I change the filePath to a different file, I get the following error:
Exception:
Message: PDF header not found. The file is not a valid PDF document.
Filename:
Function: Skipheader
Linenumber:
This happens even if I switch the filePath back to what the WebViewer was initially created with, when the file loaded without issue.
Additionally, this doesn’t happen when I am running both the React server and the API on my own machine under localhost. This only happens when we deploy them to a server, like our test server.