How to reset to "default" zoom

17 views
Skip to first unread message

Randy Haid

unread,
Mar 31, 2021, 5:35:43 PM3/31/21
to PDFTron SDK
I'm using v8.1.2 of the iOS SDK and looking for help with what I think is a zoom issue.

TLDR: When closing a document and opening a new document using the same controller, what is the magic incantation to make the new document "fit just right" in the controller?

I am inheriting from PTDocumentController, and I am reusing that view controller for any doc that I want to view.  i.e.

1. When a user first taps on a doc thumbnail in my UI, I create a PTDocumentController and use that to open and display the full doc.  Looks amazing; the document is displayed at exactly the right zoom level and I didn't even do anything to make that happen.
2. When the user "exits" the PTDocumentController, I close the document but I keep the controller "alive" so that I can reuse it...
3. When the user taps on a second thumbnail, I reuse that controller and simply call openDocument with the new document.

And that's when I run into trouble.  It's almost like the controller has decided what zoom level it wants to use for that first document, and then it keeps that zoom level for the second document.

I've tried tinkering with "pdfViewCtrl.zoom" and "pdfViewCtrl.setZoomX" with various degrees of interesting results, but I'm clearly doing something wrong.

As always, thank you for the amazing help you give. :)

Jamie Dassoulas

unread,
Apr 5, 2021, 1:12:23 PM4/5/21
to PDFTron SDK
Hi,

Thank you for getting in touch with us about this.
Are you able to share a video or images showing the behaviour you're describing as well as the expected behaviour, i.e. what you would expect to see when opening different documents?

You could try specifying the page view mode whenever you open a document:

The default view mode for a `PTDocumentController` is e_trn_fit_width which fits the page width to the viewer. The default reference page view mode however is e_trn_zoom which persists the user's current zoom across e.g. page turns.
Are you able to get your desired behaviour by setting these two properties to your preferred view modes?

Randy Haid

unread,
Apr 5, 2021, 1:27:32 PM4/5/21
to PDFTron SDK
Nice!  Setting the pageViewMode to e_trn_fit_width does exactly what I want.  Thank you!!

Jamie Dassoulas

unread,
Apr 5, 2021, 3:00:05 PM4/5/21
to PDFTron SDK
Great! I'm glad to hear that worked for you :)
No problem at all and please do get in touch with any other questions or comments and we'll try to help in any way we can.

Reply all
Reply to author
Forward
0 new messages