mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
AAE-34826 Incorrect scale for rendered pdf documents (#10857)
* AAE-34826 Fix missing class for pdf viewer * AAE-34826 Remove double initial scale * AAE-34826 Fix missing scale * AAE-34826 Remove unnecessary condition * AAE-34826 Remove surplus id * AAE-34826 converted scale to string --------- Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com>
This commit is contained in:
parent
6257510056
commit
efd6e5b1b0
@ -27,7 +27,7 @@
|
|||||||
class="adf-viewer-pdf-viewer"
|
class="adf-viewer-pdf-viewer"
|
||||||
(window:resize)="onResize()">
|
(window:resize)="onResize()">
|
||||||
<div [id]="randomPdfId + '-viewer-viewerPdf'"
|
<div [id]="randomPdfId + '-viewer-viewerPdf'"
|
||||||
class="adf-pdfViewer"
|
class="adf-pdfViewer pdfViewer"
|
||||||
role="document"
|
role="document"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
aria-expanded="true">
|
aria-expanded="true">
|
||||||
|
@ -114,7 +114,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
displayPage: number;
|
displayPage: number;
|
||||||
totalPages: number;
|
totalPages: number;
|
||||||
loadingPercent: number;
|
loadingPercent: number;
|
||||||
pdfViewer: any;
|
pdfViewer: PDFViewer;
|
||||||
pdfJsWorkerUrl: string;
|
pdfJsWorkerUrl: string;
|
||||||
pdfJsWorkerInstance: Worker;
|
pdfJsWorkerInstance: Worker;
|
||||||
currentScaleMode: PdfScaleMode = 'init';
|
currentScaleMode: PdfScaleMode = 'init';
|
||||||
@ -132,7 +132,12 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
documentOverflow = false;
|
documentOverflow = false;
|
||||||
|
|
||||||
get currentScaleText(): string {
|
get currentScaleText(): string {
|
||||||
return this.pdfViewer?.currentScaleValue ? Math.round(this.pdfViewer.currentScaleValue * 100) + '%' : '';
|
const currentScaleValueStr = this.pdfViewer?.currentScaleValue;
|
||||||
|
const scaleNumber = Number(currentScaleValueStr);
|
||||||
|
|
||||||
|
const currentScaleText = scaleNumber ? `${Math.round(scaleNumber * 100)}%` : '';
|
||||||
|
|
||||||
|
return currentScaleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private pdfjsLib = inject(PDFJS_MODULE);
|
private pdfjsLib = inject(PDFJS_MODULE);
|
||||||
@ -452,10 +457,9 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
setScaleUpdatePages(newScale: number) {
|
setScaleUpdatePages(newScale: number) {
|
||||||
if (this.pdfViewer) {
|
if (this.pdfViewer) {
|
||||||
if (!this.isSameScale(this.pdfViewer.currentScaleValue, newScale)) {
|
if (!this.isSameScale(this.pdfViewer.currentScaleValue, newScale.toString())) {
|
||||||
this.pdfViewer.currentScaleValue = newScale;
|
this.pdfViewer.currentScaleValue = newScale.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pdfViewer.update();
|
this.pdfViewer.update();
|
||||||
}
|
}
|
||||||
this.setDocumentOverflow();
|
this.setDocumentOverflow();
|
||||||
@ -468,7 +472,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
* @param newScale - new scale page
|
* @param newScale - new scale page
|
||||||
* @returns `true` if the scale is the same, otherwise `false`
|
* @returns `true` if the scale is the same, otherwise `false`
|
||||||
*/
|
*/
|
||||||
isSameScale(oldScale: number, newScale: number): boolean {
|
isSameScale(oldScale: string, newScale: string): boolean {
|
||||||
return newScale === oldScale;
|
return newScale === oldScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user