WebViewer-Server preview local file error

This post was flagged by the community and is temporarily hidden.

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Yunus,

WebViewer Server does not allow for local paths. This is why the document hosted elsewhere is able to render but not a local one. Please host this file somewhere to render it with WebViewer Server.

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.

Hi Zack,

I have seen below page and that’s why I try to preview from local file.
PDFTron Systems Inc. | Documentation

According to this page, we can upload and render local files. I thought that if we can preview local files by uploading, we can preview them directly with file path. What is difference between them? I preview the local file with upload option.

In my situation, we do not want to make the files publicly accessible directly for security reasons. So, isn’t there any way to preview local files that are exist same machine with webviewer server?

Best regards.

Hi Yunus,

The issue is specifically passing through a local path to loadDocument.

Something like this will render local files as they need to be translated into a Core.Document instance.

Webviewer({
  path: '/lib',
  webviewerServerURL: 'myWVServer:8000',
}, document.getElementById('viewer')).then( async instance => {
  const doc = await instance.Core.createDocument('path to file');
  instance.UI.loadDocument(doc);
});

The server is expecting a URL so passing in a local path cannot be read as the server does not have access to the client’s computer. If we create a document object locally, we can pass that object to loadDocument and get the file rendered on the server as it has all the information it needs.

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.

Hi Zack,

Thanks for the clarification, it’s working now.

Best regards.