ApryseSDK / webviewer-ui

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

pageComplete event not being raised #333

Closed zharchimage closed 5 years ago

zharchimage commented 5 years ago

I'm building a Typescript wrapper, and I have this code: ` var localInstance: any;

    //var docViewer = window.;

    //.addEventListener("pageComplete", (e) => {
    //    alert("pageComplete");
    //});

    localInstance = await WebViewer({
        path: '/WebViewer/lib',
        //enableFilePicker: false,
        //enableAnnotations: false,
        //enableMeasurement: false,
        //enableRedaction: false,
        //disabledElements: ['header', 'pageNavOverlay', 'viewControlsButton', 'viewControlsOverlay', 'annotationPopup', 'zoomOverlay', 'textPopup', 'toolStylePopup', 'contextMenuPopup', 'cursorOverlay'],
        initialDoc: '/api/pdf',
        //initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
    }, viewerElement);

    viewerElement.addEventListener("pageComplete", function () {

    });

    viewerElement.addEventListener("documentLoaded", function () {

    });

    viewerElement.addEventListener("pageChanged", function (event: any) {

    });`

THe PDF Is loading properly and documentLoaded and Pagechanged get called but events like pageComplete and finishedRendering never get called.

ZhijieZhang commented 5 years ago

Hi,

We dispatch the custom documentLoaded event to the viewerElement because we think this event is one of the most used events in WebViewer. However, this is not necessary since this event is the same as the one of docViewer and you could achieve the same thing by the following code:

localInstance = await WebViewer({
    path: '/WebViewer/lib',
    //enableFilePicker: false,
    //enableAnnotations: false,
    //enableMeasurement: false,
    //enableRedaction: false,
    //disabledElements: ['header', 'pageNavOverlay', 'viewControlsButton', 'viewControlsOverlay', 'annotationPopup', 'zoomOverlay', 'textPopup', 'toolStylePopup', 'contextMenuPopup', 'cursorOverlay'],
    initialDoc: '/api/pdf',
    //initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
}, viewerElement);

localInstance.docViewer.on('documentLoaded', function() {})

Because the pageComplete event isn't that often used as documentLoaded, we didn't provide the same event layer for it. To listen to the pageComplete event you can use the following code:

localInstance.docViewer.on('pageComplete', function() {})

Events like pageChanged, layoutModeChanged, zoomChanged etc are there for the purpose of legacy UI backwards compatibilities. You should be able to listen these events directly on docViewer. More available events can be found here: https://www.pdftron.com/api/web/CoreControls.DocumentViewer.html#toc86__anchor

Let me know if this helps and if you have any other questions!

zharchimage commented 5 years ago

Thanks @ZhijieZhang will check tomorrow!

zharchimage commented 5 years ago

I'm receiving loads of warning that might when loading a PDF, even if it loads properly:

image

Any idea why this is happening?

ZhijieZhang commented 5 years ago

Thanks for bringing this to our attention.

Looking at the call stacks it seems that something goes wrong when WebViewer tries to deserialize annotations. However it's hard to figure out the issue without seeing the document you are trying to load.

One option for you to send over the document is through a support form. You can fill out the form here https://www.pdftron.com/form/request.

Once we could reproduce the issue on our end, we will give you an update and the rest of the conversation will be continued in that support ticket.

Let me know if you have any other questions. Thanks!

ZhijieZhang commented 5 years ago

I will close this issue for now because from the call stacks, the errors are from the CoreControls.js, not UI.

@potudopotudo If you'd like this issue to be sorted out, please fill out the form and kindly send the document so that we can try to reproduce the issue on our end and investigate further. Thanks!