Zoom to a location on load

Hi,

I am currently working on PDFTron and i have a requirement to zoom to a certain location on pdf when user performs a click on UI. We are saving the (x,y) coordinates in databases, so when user performs the click i need to zoom to (x,y) location and create a circle annotation.

Currently i am able to draw the annotation at given (x,y) but unable to shift the view to the location.

Please let me know how to achieve this functionality

Hi Sravan,

If you are able to create an annotation at the location (x, y) then you can pass that annotation to the jumpToAnnotation API to scroll the viewer to that annotation. Does this solution work for you?

If this API doesn’t work well in your use case, can you clarify a bit more about how you are wanting to zoom to a location? For example, what’s the new zoom level you want to get? Where should the annotation show in the viewport? My current understanding is that by “zoom” you actually mean “scroll”.

Best Regards,
Zhijie Zhang
Software Developer
PDFTron Systems Inc.

Hi Below is my expectation of zoom. Initally the viewer will be loaded with 120% zoom, so on click i expect the zoom of the viewer as below and scrolled to that x,y position.

Let me know if any further details are required. In the mean time i will try jumpToAnnotation as suggested.

demo.png
Thanks,
Sravan.

Hi Sravan,

Thanks for sharing the screenshot but I don’t think I see the zoom level in it. So I’m assuming the zoom level is still 120%, but the viewer is scrolled? If this is the case then I think jumpToAnnotation should work.

Best Regards,
Zhijie Zhang
Software Developer
PDFTron Systems Inc.

Hi,

Actually zoom is not 120% it is more than 120%, around 600%. Basically I need to scroll to that location and also adjust my zoom so that it is clear to the user.

Thanks,
Sravan.

Hi Sravan,

Just to clarify that you’ve tried the jumpToAnnotation? If it doesn’t work as you expected can you elaborate more?

Best Regards,
Zhijie Zhang
Software Developer
PDFTron Systems Inc

Yes, I have tried it. I was able to jump to the page but not able to zoom to that location. My zoom is still at initial value when viewer is loaded

Hi Sravan,

Thanks for the clarification. If you would like the viewer to zoom in then you can call instance.setZoomLevel with the desired zoom level before you call jumpToAnnotation.

Thanks,
Zhijie Zhang
Software Developer
PDFTron Systems Inc.