Skip to content

The zoom automatically resets to 'auto' without the input property being changed. #294

@leominaudo

Description

@leominaudo

Even if I pass the 'page-width' value to the 'zoom' input property, the component automatically switches to 'auto' mode.
I tried logging the zoom change, and it initially outputs the passed value, followed by 'auto'.

Combination not working:

<ng2-pdfjs-viewer
  #pdfViewer
  [viewerId]="viewerId()"
  [pdfSrc]="pdfSrc()"
  [downloadFileName]="downloadFileName()"
  [errorMessage]="errorMessage()"
  [errorOverride]="errorOverride()"
  [controlVisibility]="controlVisibilityConfig()"
  [zoom]="zoom()"
  [urlValidation]="false"
  (onDocumentLoad)="documentLoad.emit($event)"
  (onBeforePrint)="beforePrint.emit($event)"
  (onAfterPrint)="afterPrint.emit($event)"
/>
export class MyComponent {
  ...
  public readonly zoom = input<'auto' | 'page-width' | 'page-height' | 'page-fit'>('page-width');
  ...
}

Temporary solution to my problem:

<ng2-pdfjs-viewer
  #pdfViewer
  [viewerId]="viewerId()"
  [pdfSrc]="pdfSrc()"
  [downloadFileName]="downloadFileName()"
  [errorMessage]="errorMessage()"
  [errorOverride]="errorOverride()"
  [controlVisibility]="controlVisibilityConfig()"
  [zoom]="zoom()"
  [urlValidation]="false"
  (onDocumentLoad)="documentLoad.emit($event)"
  (onBeforePrint)="beforePrint.emit($event)"
  (onAfterPrint)="afterPrint.emit($event)"
  (onDocumentInit)="documentInit()"
/>
export class MyComponent {
  ...
  public readonly zoom = input<'auto' | 'page-width' | 'page-height' | 'page-fit'>('page-width');
  protected readonly pdfViewer = viewChild<PdfJsViewerComponent>('pdfViewer');
  ...
 protected documentInit(): void {
    this.pdfViewer()?.setZoom(this.zoom());
  }
}
"ng2-pdfjs-viewer": "25.0.18"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions