I have trouble using UIGraphicsSetPDFContextURLForRect() function. In what coordinate system is this rect positioned. I have tried to play with the context and its ctm but nothing seem to work.
This code produces text at the bottom of the page and the url link at the very top of the pdf document page.
What should I do to have the text and the url at the same place?
This code produces text at the bottom of the page and the url link at the very top of the pdf document page.
Code:
- (NSData *)pdfDataByDrawingDocument
{
CGRect docFrame = CGRectMake (0., 0., 512., 740.);
CGRect fldFrame = CGRectMake (0., docFrame.size.height-30., docFrame.size.width, 30.);
// set up PDF rendering context
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData (pdfData, docFrame, nil);
UIGraphicsBeginPDFPage ();
UIGraphicsSetPDFContextURLForRect ([NSURL URLWithString:@"https://www.macrumors.com"], fldFrame);
[@"Hello macrumors!" drawInRect:fldFrame
withFont:[UIFont systemFontOfSize:20.]
lineBreakMode:UILineBreakModeWordWrap
alignment:NSTextAlignmentCenter];
UIGraphicsEndPDFContext (); // remove PDF rendering context
return (pdfData);
}
What should I do to have the text and the url at the same place?
Last edited: