Zooming

PdfFragment allows you to programmatically zoom to a certain scale, or an area of a PDF document page using a convenient zooming API.

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 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();