Programmatically setting the zoom level of the PDF document

Hello,

I'm trying to programmatically set the zoom of the PDF-viewer. Adapting your example on the demo page I have:

<ejs-pdfviewer #viewerObj id="pdfViewer" [serviceUrl]='service' [documentPath]='document'
style="height:80vh; display:block" (downloadStart)="onInitialise()">
</ejs-pdfviewer>


@ViewChild('viewerObj')
public viewerObj: PdfViewerComponent;

public service = 'https://ej2services.syncfusion.com/production/web-services/api/pdfviewer';
public document = 'PDF_Succinctly.pdf';

constructor() {
}

ngOnInit(): void {
}

onInitialise(event) {
this.viewerObj.zoomMode = 'FitToPage';
}

However even when the FitToPage is set - nothing changes. If I refresh() the whole thing refreshes (as I would expect). Is there some other steps that are required to get this functionality working?

Thanks,

Sean



1 Reply

AA Akshaya Arivoli Syncfusion Team June 30, 2020 03:15 PM UTC

Hi Sean, 

Thank you for contacting Syncfusion Support. 

We need to provide zoomMode property during the control initialization. Please find the sample for the same form the below, 
We can also use viewer.magnification.fitToPage() in onInitialise method. Please try it and revert us with more details about your requirement and the modified sample, if you need further assistance. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya  


Loader.
Up arrow icon