iOS how to opening the pdf from a https link

26 views
Skip to first unread message

Lizelle Bekker

unread,
Jan 24, 2018, 12:19:14 PM1/24/18
to PDFTron PDFNet SDK
I'm trying to open a pdf document from a url and then going to a specific page number. I'm using the below snippet but it just stays blank. 
1 Kindly please provide an working obj-c sample for a https link that downloads the pdf file.
2 How to check to see if the download failed or is in progress?
3 Is there a an activity indicator on the PTPDFViewCtrl that could be switched on?

[PTPDFViewCtrl OpenUrlAsync: WithPDFPassword:@""];

Ryan

unread,
Jan 24, 2018, 2:58:14 PM1/24/18
to PDFTron PDFNet SDK
1. I believe the CompleteReader sample exposes the OpenUrlAsync method in the UI, so you can search the sample code for the call.

Normally the call would be something like the following.


As for listening for errors or to check if the download is finished, you can either check the sample code for usage, or use this template.

2. You can check the current download state through PDFViewCtrl.DownloadTypes:

 void HandleDownloadEventType (object sender, PDFViewCtrl.DocumentDownloadedEventArgs e)
 
{
 
PDFViewCtrl.DownloadTypes type = (PDFViewCtrl.DownloadTypes)sender;
 
if (type == PDFViewCtrl.DownloadTypes.e_downloadtype_opened)
 
{
 
// can now get the page count
 
}
 
else if (type == PDFViewCtrl.DownloadTypes.e_downloadtype_finished)
 
{
 
// finished
 
}
 
else if (type == PDFViewCtrl.DownloadTypes.e_downloadtype_failed)
 
{
 
// failed
 
}
 
}


3. No, this would something you can add. You can track progress by page count.

Shakthi Wijeratne

unread,
Jan 24, 2018, 3:11:23 PM1/24/18
to PDFTron PDFNet SDK
To add to Ryans answer, please see the iOS specific API calls to check for download status here:
https://www.pdftron.com/pdfnet/mobile/docs/iOS/src/Protocols/PTPDFViewCtrlDelegate.html#/c:objc(pl)PTPDFViewCtrlDelegate(im)downloadEventType:pageNumber:

To see a working example of this under iOS, please refer to the PDFViewCtrl sample project (specifically, go to RootViewController.m:155, and uncomment the OpenUrlAsync method.).
Reply all
Reply to author
Forward
0 new messages