ApryseSDK / webviewer-ui

WebViewer UI built in React
Other
416 stars 353 forks source link

Thumbnails do not always render for PDF files #15

Closed henry-chris closed 6 years ago

henry-chris commented 6 years ago

Repro Steps - v1 React UI

First:

  1. https://www.pdftron.com/webviewer/demo/
  2. Grab almost any PDF on your computer and upload it via the 'Open file' menu.
  3. Watch as no thumbnails are rendered.

Most of the PDFs loaded by 'Open by url' work decently.

Second: In our modified version v1 (v4?) webviewer UI, we cannot get any PDFs to load thumbnails. In the beta UI, everything loaded just fine.

Our webviewer constructor -

    ` <script src='~/webviewer.min.js'></script>
    <script>
      var myWebViewer = new PDFTron.WebViewer({
          path: './',
          html5Path: './ui/index.html',
          l: 'Our license',
          enableAnnotations: true,
          documentType: "pdf",
          showLocalFilePicker: true
      }, 
      document.getElementById('pdfViewer'));        
      </script>`

Extra settings we are using -

(window as any).readerControl.enableAnnotations();
store.dispatch(actions.setDocumentPath(url));  // This is to any PDF url
store.dispatch(actions.setDocumentType("pdf"));
store.dispatch(actions.setEngineType('pdfnetjs'));
store.dispatch(actions.setUseDownloader(false));
store.dispatch(actions.setServerUrl(null));
store.dispatch(actions.openElement('loadingModal'));
loadDocument(store.getState(), store.dispatch);

So, for us NO pdf will display rendered thumbnails at all. And your demo viewer only displays them when loading from a URL, but not from a local file.

I've only tested in Chrome. I'm not sure if the demo issue is associated with us not being able to view any thumbnails or not, but it seems like it is. I have not reproduced this specifically in the open source version of the UI, so let me know if I need to give you more information.

Also, this might not specifically be related to the UI, so my apologies if this issue is errant.

henry-chris commented 6 years ago

Update: From this repo, I can run the samples...but I'm having a lot of trouble just running the UI with the dev server. It's using my global webpack-cli, which is newer than your version and does not work correctly with your version of webpack. When I fix that, there it can't find the 'babel-preset-react'. Probably because I had to update webpack to a newer version for the previous problem. We use babel 7.0 with a .babelrc file (you guys had one in your beta source code) so it's hard to directly pinpoint my issue.

However, running the samples, it seems like you point to 'demo.pdftron.com' to load everything. Once I commented that out, you can just run the sample 'Viewing sample' and reproduce the thumbnail issue.

image

They don't even render with your default PDF, but the annotations render on the page fine somehow. This is the exact problem we are seeing, as we currently default to client only in Chrome.

The only changed code (viewing.js):

// Instantiate
var viewerElement = document.getElementById('viewer');
var viewer = new PDFTron.WebViewer({
  path: '../../../lib',
  l: window.sampleL,
  **//pdftronServer: 'https://demo.pdftron.com/', // comment this out to do client-side only**
  initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo-annotated.pdf'
}, viewerElement);
justinjung04 commented 6 years ago

Hi Henry,

Thank you for the all the details. We were able to reproduce the issue on our end, and we'll come up with a fix soon.

It's sad to hear the sample doesn't run with the newer version of webpack. We'll investigate if there's anything we can to to mitigate it.

henry-chris commented 6 years ago

It's sad to hear the sample doesn't run with the newer version of webpack. We'll investigate if there's anything we can to to mitigate it.

Oh, it seems to be an issue with webpack with newer versions of webpack CLI. It's my own computers fault, but I was stumped by it using my global CLI version. I can't find the issue right now, but

Here's a link that references the issue I think.

Also, great to hear about reproducing the thumbnail issue.