ianM
ianM

Reputation: 393

hyperlink not working in a pdf in a UIWebView

I have text file (instructions.docx) with a hyperlink in it - I convert it to a pdf (instructions.pdf) and use it in a UIWebView as follows:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Instructions" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
[_webView setScalesPageToFit:YES];

All works fine except the hyperlink does not work - shows blue - but tapping it does nothing. Am I going about this the wrong way - or am I missing something?

Upvotes: 1

Views: 1676

Answers (2)

ShannonS
ShannonS

Reputation: 364

I had a similar problem. Turns out the links in the PDF weren't hyperlinks. They were just typed in (even though they were blue and looked like real hyperlinks).

Resolved the issue by:

  1. Manually adding hyperlinks
  2. Checked Word to PDF conversion allowed for "Best for electronic distribution and accessibility"

Upvotes: 0

etolstoy
etolstoy

Reputation: 1798

I'm not sure, but you can try this line of code:

[_webView setDataDetectorTypes:UIDataDetectorTypeLink];

Otherwise, you can try Reader library by vfr. PDF embedded links work in it.

Also you may want to take a look at this question.

Upvotes: 1

Related Questions