I am creating a PDF using UIGraphicsBeginPDFContextToFile in iOS, where I want to add URL links to other pages as well as other websites. Below is the code : here pdfObj is a custom class which draws text to PDF. After Succesfull creation of PDF nothing happens if I clicks the area for "GO to Chapter1" and "GO to URL"
UIGraphicsBeginPDFContextToFile(documentDirectoryFilename, CGRectZero, nil);
UIGraphicsBeginPDFPage();
//Page 1
UIGraphicsAddPDFContextDestinationAtPoint(@"Chapter1", CGPointMake(0, 0));
//other draw pdf data....
//Page 2
UIGraphicsBeginPDFPage();
//other draw pdf data....
[pdfObj addHeaderText:@"Go to Chapter 1" atFrame:CGRectMake(50, 50, 200, 44)];
UIGraphicsSetPDFContextDestinationForRect(@"Chapter1", CGRectMake(50, 50, 200, 44));
[pdfObj addHeaderText:@"Go to URL" atFrame:CGRectMake(550, 550, 200, 44)];
UIGraphicsSetPDFContextURLForRect([NSURL urlWithString:@"http://www.myURL.com"], CGRectMake(550, 550, 200, 44));
UIGraphicsEndPDFContext();
Please let me know what mistake I am making here
check the answer to this question it works:Embed hyperlink in PDF using Core Graphics on iOS