CopperPDF icon indicating copy to clipboard operation
CopperPDF copied to clipboard

Don't show document-related menu items until document loaded

Open Lesik opened this issue 7 years ago • 3 comments

As discussed with @Tommy-Geenexus in #7, this PR implements an onDocumentLoaded callback that enables document-related menu items such as printing.

One thing I'm not 100% happy with is that the callback is run a lot earlier than when the whole page is actually rendered. Maybe @Tommy-Geenexus can help?

Lesik avatar Dec 28 '17 22:12 Lesik

Thanks @Lesik. Let's see if @Tommy-Geenexus chimes in, otherwise I'll merge this as it is, if you agree.

paride avatar Dec 29 '17 10:12 paride

@Lesik @paride I will take a look over the course of the weekend, when i'm free.

Tommy-Geenexus avatar Dec 29 '17 11:12 Tommy-Geenexus

@Lesik @paride

Sorry for the delay. There is a way to catch page rendering when its finished; below is a sample on how it could be implemented via a js callback (in viewer.js).

var renderTask = page.render(renderContext);

    renderTask.promise.then(function () {
        channel.onPageLoaded(); <- Implement callback here
        pageRendering = false;
        if (pageNumPending !== null) {
            renderPage(pageNumPending);
            pageNumPending = null;
        }
    });

I can't contribute code atm, as i'm very busy, but i hope this helps.

Tommy-Geenexus avatar Jan 02 '18 20:01 Tommy-Geenexus