'PDFTron iOS and Android how to open the PdfViewCtrl at a specific page?
We are using the PDFTron SDK to read PDFs in our Xamarin app. What we want to do is open the PDF at a specific page, since we want our users to continue reading where they left on our website.
We are following the example found here, with the PTTabbedDocumentViewController on iOS. Here is what we tried, to make this work.
PDFDoc pdfDoc = TypeConvertHelper.ConvPdfDocToManaged(mTabViewController.SelectedViewController.PdfViewCtrl.GetDoc());
if (pdfDoc != null)
{
var pageCount = pdfDoc.GetPageCount();
}
But, the pdfDoc instance is always null. Please, can someone help?
Solution 1:[1]
Android
There is a method to start the viewer on a specific page: https://www.pdftron.com/api/xamarinandroid/pdfnet/api/pdftronprivate.PDF.PDFViewCtrl.html#pdftronprivate_PDF_PDFViewCtrl_CurrentPage: ?
Here is a code sample:
var myPage = 3;
mPdfViewCtrl.DocumentLoad += (sender, e) =>
{
// On document loaded, set the page
mPdfViewCtrl.CurrentPage = myPage;
};
iOS:
For iOS the equivalent method is this: https://www.pdftron.com/api/xamarinios/tools/api/pdftron.PDF.PTPDFViewCtrl.html#pdftron_PDF_PTPDFViewCtrl_SetCurrentPage_System_Int32_
mPdfViewCtrl.OnSetDoc += (sender, e) =>
{
mPdfViewCtrl.SetCurrentPage(3);
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew |
