Get current vertical and horizontal offsets in UWP PDF Viewer

8 Jun 20211 minute to read

The SfPdfViewer control provides the value of the current vertical and horizontal offsets. The following code allows you to access the same. Here ‘buffer’ is the byte array read from the PDF file either using FileOpenPicker or from Assets folder, as illustrated in the Viewing PDF section.

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Gets Vertical Offset of a document.
float vOffset = pdfViewer.VerticalOffset;
//Gets Horizontal Offset of a document.
float hOffset = pdfViewer.HorizontalOffset;
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Gets Vertical Offset of a document.
Dim vOffset As Single = pdfViewer.VerticalOffset
'Gets Horizontal Offset of a document.
Dim hOffset As Single = pdfViewer.HorizontalOffset