Zooming
PdfFragment
allows you to programmatically zoom to a certain scale or to an area of a PDF document page using a convenient zooming API.
PdfFragment#zoomTo(RectF, int, long)
allows you to zoom to a specificRectF
on the given page.PdfFragment#zoomTo(int, int, int, float, long)
lets you zoom to a focus point at the given scale.
ℹ️ Note: Both methods take PDF page coordinates. To find out more on that topic, see the guide on coordinate space conversion.
You can also easily get the current zoom level of a page by calling PdfFragment#getZoomScale
.
Disable Zooming
Zooming can be disabled by setting maxZoomScale
of PdfConfiguration
to 1
. It’s important to set this value before creating the view:
1 2 3 | val configuration = PdfConfiguration.Builder() .maxZoomScale(1.0f) .build() |
1 2 3 | final PdfConfiguration configuration = new PdfConfiguration.Builder() .maxZoomScale(1.0f) .build(); |
Starting the Document at a Given Scale
A document can be started at an already pre-determined scale (on the given page). Note that rotating the screen resets the scale. The property that controls this is startZoomScale
in PdfConfiguration
:
1 2 3 | val configuration = PdfConfiguration.Builder() .startZoomScale(3.0f) .build() |
1 2 3 | final PdfConfiguration configuration = new PdfConfiguration.Builder() .startZoomScale(3.0f) .build(); |