Zoom using buttons and reset zoom when page changed
Hi. First of all, thank you very much for working with this library and sorry for my English.
I would like to know if there is a way to zoom using buttons, I need to do it that way and be able to move in the pdf once that zoom is done. Is this possible?
On the other hand if I zoom in on one page, then move on to another and return to the previous one, the zoom is maintained. Could the zoom be reset when the page is changed?
Thanks again
Hi!
I'm afraid you can't specify a concrete zoom level programatically, but you can try setting the scale. Other library users like #3, #8 or #67 used the scale to simulate zooming. And I guess you can set it back to its initial value in onPageSelected, doing the reset task.
Let me know if this does the trick for you
Hi!
I was able to reset the zoom of any page when returning to it by doing:
@Override
public void onPageSelected(int position) {
SubsamplingScaleImageView v = (SubsamplingScaleImageView)((FrameLayout)pdfViewPager.getChildAt(position)).getChildAt(1);
v.resetScaleAndCenter();
}
This seems to work correctly. However, I can't zoom through the buttons, I understand that if in "SubsamplingScaleImageView" I do "setScaleX()" and "setScaleY" should work, the values are updated but the view does not change...
This is so? Thanks!!
Maybe it's simpler than this, as in the issue #8, you can directly set the scale to the PdfViewPager
pdfViewPager.setScaleX(1.5f);
then setting it back to 1f will maybe reset the zoom. I haven't tried that, but it's what the other users are saying in their issues
Other solution would be to implement your own custom adapter (it's not difficult, just copy and paste PdfPagerAdapter), then add a method that can directly set the zoom level of the SubsamplingScaleImageView. I haven't tried that either 😅
Maybe it's simpler than this, as in the issue #8, you can directly set the scale to the PdfViewPager
pdfViewPager.setScaleX(1.5f);then setting it back to
1fwill maybe reset the zoom. I haven't tried that, but it's what the other users are saying in their issues
This solution had already been tested, which happens that the aspect ratio is not maintained, so the letters of the pdf look like "stretched". If I apply the same 1.5f value for "scaleY", the view does not maintain its size (it had the view under two buttons and thus the buttons disappear...). Do you know why this happens?
Thank you for everything!