Is it possible to programmatically zoom at a certain point on a PDF?

I need a PDF viewer that is able to programmatically zoom at a certain point on the PDF file. By this I mean, for instances:

viewer.zoomAt(xCoord, yCoord, page), or something similar to this. Is this possible with Syncfusion's PDF viewer? 

7 Replies

MS Mohan Selvaraj Syncfusion Team April 10, 2020 08:07 AM UTC

Hi Leonardo , 

Thanks for using Syncfusion products. 

At present we don’t have support for zooming the PDF file by using the X and Y coordinates with respect to page. However you can zoom the PDF file by Zooming the PDF document to the given zoom value and also with out providing the zoom value. Kindly refer the API Documentation for more details for using the PDF Viewer control. 

Please refer the code-snippet below. 

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> 
<SfPdfViewerServer @ref="viewer" DocumentPath="@DocumentPath" Height="30%" Width="100%"> 
</SfPdfViewerServer> 
 
@code{ 
    SfPdfViewerServer viewer; 
    private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf"; 
    private void IncrementCount() 
    { 
        viewer.GetMagnification().ZoomTo(200); //It will gets zoomed to the 200 percentage. 
 
       // viewer.GetMagnification().ZoomIn(); // The control will gets zoomed in. 
       // viewer.GetMagnification().ZoomOut();//The control will gets zoomed out. 
    } 
} 

Note: you can use any of the method for performing zooming. 

If the above provided details doesn’t matches your criteria. Kindly provide more details about that query. So that would be helpful for us to analysis more and proceed further. 

Regards, 
Mohan S 



LE Leonardo Estrela April 13, 2020 01:45 PM UTC

Hey! Thank you for the response.

Would it be possible to programmaticaly pan on the PDF viewer? Perhaps through the vertical and horizontal scroll bars? I am still not sure how I would make it work, but if I could do this it would probably be a step on the right direction.

My objective is to be able to "focus" on a word on the PDF, zoom and center on it.


AA Akshaya Arivoli Syncfusion Team April 14, 2020 10:26 AM UTC

Hi Leonardo, 

Thank you for your update 

We are unable to get your requirement exactly, can you please provide more details about your requirement and the use case scenario. Also can you please confirm us whether you want to scroll to the particular location by providing its coordinates else you want to zoom a particular word to the center of the PDF Viewer. However, we can search for the required word to highlight that word  in PDF Viewer. 


Please try it and revert us with more details. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 



LE Leonardo Estrela April 14, 2020 11:22 AM UTC

Thank you for the response
I want to know if there is any way to zoom and center on a certain point of the PDF (not necessarily a word). If I can't achieve this through coordinates, is there any other way this can be achieved?


AA Akshaya Arivoli Syncfusion Team April 15, 2020 01:47 PM UTC

Hi Leonardo, 
  
Thank you for your update. Currently we do not have support to zoom and center on a certain point of the PDF from code behind using PDF Viewer and we do not have any plan to implement the same. 
  
Regards, 
Akshaya 



TK TaeWook Kang February 21, 2022 10:51 AM UTC

Hi. I also need the function Leonardo wants. Don't you still support that function? :(



DM Dhivyabharathi Mohan Syncfusion Team February 22, 2022 02:54 PM UTC

Hi TaeWook, 
 
You can search the particular word using the searchText method available in the PDF Viewer and then you can perform the zooming actions using the ZoomTo method. We have shared the sample and code snippet for your reference. 
 
 
Code snippet: 
 
function SearchTextZoom() { 
        var viewer = document.getElementById('pdfviewer1').ej2_instances[0]; 
        viewer.textSearchModule.searchText('Resources', false); 
        viewer.magnificationModule.zoomTo(125); 
    } 
 
 
Kindly try this and revert to us, if you need further assistance. 
 
Regards, 
Dhivya.             

Loader.
Up arrow icon