ngx-extended-pdf-viewer - access canvas of each page and handle events

375 Views Asked by At

In my angular app I'm currently trying to access the canvas of each PDF page using ngx-extended-pdf-viewer. Currently, I'm able to extract the canvases in the onPagesLoaded event method the library provides, like so:

    onPagesLoaded(event: PagesLoadedEvent) {
        this.canvas = this._document.getElementsByTagName('canvas')[0];
        if (this.canvas) {
            this.ctx = this.canvas.getContext('2d');
    
            if (this.ctx) {
                this.ctx.strokeStyle = 'black'
                this.ctx.lineWidth = 2;
                this.handleCanvasEvent();
            }
        }
    }

The problem I'm facing is that the canvas for each page seems to be so buried in the DOM tree that I can't really listen to the events I need to listen to such as mousemove, mouseup and mousedown. I need this to be possible as I want to be able to draw on the canvas of the page.

Anyone here with experience using this library and manipulating the canvas of the pages that could help me out?

0

There are 0 best solutions below