You can try PDFKitten. It has a code.
- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGPDFDocumentRef doc = CGPDFDocumentRetain(self.document);
CGPDFPageRef page = CGPDFDocumentGetPage(doc, 1);
CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, layer.bounds, 0, YES));
CGContextDrawPDFPage(ctx, page);
for (Selection *s in self.selections)
{
CGContextSaveGState(ctx);
CGContextConcatCTM(ctx, [s transform]);
CGContextSetFillColorWithColor(ctx, [[UIColor yellowColor] CGColor]);
CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
CGContextFillRect(ctx, [s frame]);
CGContextRestoreGState(ctx);
}
CGPDFDocumentRelease(doc); doc = nil;
}
source
share