# PdfView.OnViewportChangedListener

Artifact: [androidx.pdf:pdf-viewer](https://developer.android.com/jetpack/androidx/releases/pdf) [View Source](https://cs.android.com/search?q=file:androidx/pdf/view/PdfView.kt+class:androidx.pdf.view.PdfView.OnViewportChangedListener) Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

*** ** * ** ***


```
public interface PdfView.OnViewportChangedListener
```

<br />

*** ** * ** ***

Listener interface to receive changes to the viewport, i.e. the window of visible PDF content

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/pdf/view/PdfView.OnViewportChangedListener#onViewportChanged(kotlin.Int,kotlin.Int,android.util.SparseArray,kotlin.Float)( int firstVisiblePage, int visiblePagesCount, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html> pageLocations, float zoomLevel )` Called when there has been a change in visible PDF content |

## Public methods

### onViewportChanged

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
@MainThread
abstract void onViewportChanged(
    int firstVisiblePage,
    int visiblePagesCount,
    @NonNull SparseArray<@NonNull RectF> pageLocations,
    float zoomLevel
)
```

Called when there has been a change in visible PDF content

| Parameters |
|---|---|
| `int firstVisiblePage` | the first page that's visible in the View, even if partially so |
| `int visiblePagesCount` | the number of pages that are visible in the View, including partially visible pages |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html> pageLocations` | the location of each page in View coordinates. At extremely low zoom levels, only the first 100 page locations will be provided, and the rest can be obtained from `https://developer.android.com/reference/androidx/pdf/view/PdfView#pdfToViewPoint(androidx.pdf.PdfPoint)`. `https://developer.android.com/reference/android/graphics/Rect.html` instances are recycled; make a copy of any you wish to make use of beyond the scope of this method. |
| `float zoomLevel` | the current zoom level |