We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PDF doesn't fit to the width if the tab is changed while it is loading

Hello,

I would like to report a bug with loss of scale (the PDF no longer fits to the width). 

This happens if we do not allow the document to load fully and during the loading process we change the tab. Then, after returning to the tab where the document was loaded, it is mismatched to the width of the container.

I am using the PDF Viewer v. 20.3.56. I also tried v. 20.3.59, but it didn't help.

Issue's replicable sample: stackblitz

PS. I have attached a video showing the problem and sample code. 


Best Regards,

Ignacy Mielniczek


Attachment: PDFloading_bb3c9811.zip

2 Replies 1 reply marked as answer

CK Chinnamunia Karthik Chinna Thambi Syncfusion Team December 6, 2022 01:50 PM UTC

You need to update the PDF Viewer container each time you switch the tabs. This will resolve the fit to page issue. You can refer to the sample shared in the following link and let us know if you have any queries.



Sample: PDF Viewer in Tabbed control

  

In tab.component.html

 

<ejs-tab id="element"  (selected)="selected($event)">

  <e-tabitems>

    <e-tabitem>

      <ng-template #headerText>

        <div>Tab1</div>

      </ng-template>

      <ng-template #content> {{ content1 }} </ng-template>

    </e-tabitem>

    <e-tabitem>

      <ng-template #headerText>

        <div>Tab2</div>

      </ng-template>

      <ng-template #content> <hello></hello> </ng-template>

    </e-tabitem>

    <e-tabitem>

      <ng-template #headerText>

        <div>Tab3</div>

      </ng-template>

      <ng-template #content> --> Tab content --> Content Item </ng-template>

    </e-tabitem>

  </e-tabitems>

</ejs-tab>

 

 

In tab.component.ts

 

    public selected(args) { 

      console.log(args);

      var pdfViewer = (<any>document.getElementById('pdfViewer'));

      if(pdfViewer && pdfViewer.ej2_instances){

        var viewer = pdfViewer.ej2_instances[0];

        viewer.updateViewerContainer();

      }

    } 

 


Marked as answer

IM Ignacy Mielniczek December 8, 2022 12:43 PM UTC

Thank you very much for a quick response. I am glad to inform you that the issue which I was facing is resolved.


Best Regards,
Ignacy Mielniczek

Loader.
Live Chat Icon For mobile
Up arrow icon