Hello guys!
I am rendering my pdf in an UIView's drawRect method.
Here's my code:
- (void)drawRect:(CGRect)rect2 {
NSString *filename = @"lol.pdf";
CFStringRef path = CFStringCreateWithCString (NULL, [filename UTF8String], kCFStringEncodingUTF8);
CFURLRef url = CFURLCreateWithFileSystemPath (NULL, path, kCFURLPOSIXPathStyle, 0);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(url);
CGPDFPageRef page = CGPDFDocumentGetPage (pdf, 1);
CGAffineTransform m;
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect aRect = CGRectMake(0, 0, 768, 1024);
CGContextTranslateCTM(context, 0.0, aRect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
m = CGPDFPageGetDrawingTransform (page, kCGPDFMediaBox, aRect, 0, YES);
CGContextSaveGState (context);
CGContextConcatCTM (context, m);
CGContextClipToRect (context,CGPDFPageGetBoxRect (page, kCGPDFCropBox));
CGContextDrawPDFPage (context, page);
CGContextRestoreGState (context);
}
It renders the whole pdf. How can I render only a part from it? Can you help me with it?