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:
Wojciech Duda 2025-05-15 13:50:36 +02:00 committed by GitHub
parent 6257510056
commit efd6e5b1b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -27,7 +27,7 @@
class="adf-viewer-pdf-viewer"
(window:resize)="onResize()">
<div [id]="randomPdfId + '-viewer-viewerPdf'"
class="adf-pdfViewer"
class="adf-pdfViewer pdfViewer"
role="document"
tabindex="0"
aria-expanded="true">

View File

@ -114,7 +114,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
displayPage: number;
totalPages: number;
loadingPercent: number;
pdfViewer: any;
pdfViewer: PDFViewer;
pdfJsWorkerUrl: string;
pdfJsWorkerInstance: Worker;
currentScaleMode: PdfScaleMode = 'init';
@ -132,7 +132,12 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
documentOverflow = false;
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);
@ -452,10 +457,9 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
*/
setScaleUpdatePages(newScale: number) {
if (this.pdfViewer) {
if (!this.isSameScale(this.pdfViewer.currentScaleValue, newScale)) {
this.pdfViewer.currentScaleValue = newScale;
if (!this.isSameScale(this.pdfViewer.currentScaleValue, newScale.toString())) {
this.pdfViewer.currentScaleValue = newScale.toString();
}
this.pdfViewer.update();
}
this.setDocumentOverflow();
@ -468,7 +472,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
* @param newScale - new scale page
* @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;
}