Angular 如何在ng2 pdf viewer中获取缩放前后的页面宽度和高度

Angular 如何在ng2 pdf viewer中获取缩放前后的页面宽度和高度,angular,Angular,我正在使用Fabricjs和pdf库在pdf上添加图像。织物以pdf格式绘制画布。它工作得很好,但是当我使用ng2 pdf viewer zoom属性缩放pdf时,我需要在画布上用新的坐标和大小重新渲染图像。 我用的是公式 Xnew = Xold*newWidth/oldWidth Ynew = Yold*newWidth/oldHeight. 流程如下: 1.用户选择缩放值,该值在更改事件时调用incrementZoom方法 <select [(ngModel)]="zoom

我正在使用Fabricjs和pdf库在pdf上添加图像。织物以pdf格式绘制画布。它工作得很好,但是当我使用ng2 pdf viewer zoom属性缩放pdf时,我需要在画布上用新的坐标和大小重新渲染图像。 我用的是公式

Xnew = Xold*newWidth/oldWidth
Ynew = Yold*newWidth/oldHeight.
流程如下:

1.用户选择缩放值,该值在更改事件时调用incrementZoom方法

<select [(ngModel)]="zoomValue" (change)="incrementZoom($event)" value="1">
    <option class="option-text" value="0.5">50%</option>
    <option class="option-text" value="1" selected>100%</option>
    <option class="option-text" value="2.0">200%</option>
</select>
我还尝试从NG2PDF查看器中获取目标的宽度和高度

pageRendered(e: any) {
        this.size.width = e.source.canvas.width
        this.size.height = e.source.canvas.height
        this.canvas.setWidth(this.size.width);
        this.canvas.setHeight(this.size.height);
        var textLayer = document.getElementsByClassName('textLayer')[0];
        this.newWidth = textLayer.getBoundingClientRect().width;
        this.newHeight = textLayer.getBoundingClientRect().height;
        var pdf_viewer = document.getElementById('pdfContainer');
        this.canvasLeftPos = textLayer.getBoundingClientRect().left-pdf_viewer.getBoundingClientRect().left;
        
    }
但它不起作用,我得到了相同的旧值的宽度和高度的oldWidth和newWidth。

pageRendered(e: any) {
        this.size.width = e.source.canvas.width
        this.size.height = e.source.canvas.height
        this.canvas.setWidth(this.size.width);
        this.canvas.setHeight(this.size.height);
        var textLayer = document.getElementsByClassName('textLayer')[0];
        this.newWidth = textLayer.getBoundingClientRect().width;
        this.newHeight = textLayer.getBoundingClientRect().height;
        var pdf_viewer = document.getElementById('pdfContainer');
        this.canvasLeftPos = textLayer.getBoundingClientRect().left-pdf_viewer.getBoundingClientRect().left;
        
    }