I am working in an app which displays map in pdf. In that I am having the basic map pdf (pdf1) on top of which I need to show another pdf (pdf2) layer which is having cities name.
I am able to do so by adding another CATiledLayer object on the view like below:
NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"pdf"];
NSURL *pdfURL = [NSURL fileURLWithPath:filePath];
CGPDFDocumentRef myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);
_PDFPageRef = CGPDFDocumentGetPage(myDocumentRef, 1);
CATiledLayer *tiledLayer = [CATiledLayer layer];
tiledLayer.delegate = self;
tiledLayer.levelsOfDetail = 3; // Zoom levels
tiledLayer.levelsOfDetailBias = 3; // Bias
tiledLayer.backgroundColor = [UIColor clearColor].CGColor;
UIScreen *mainScreen = [UIScreen mainScreen]; // Main screen
CGFloat screenScale = [mainScreen scale]; // Main screen scale
CGRect screenBounds = [mainScreen bounds]; // Main screen bounds
CGFloat w_pixels = (screenBounds.size.width * screenScale);
CGFloat h_pixels = (screenBounds.size.height * screenScale);
CGFloat max = ((w_pixels < h_pixels) ? h_pixels : w_pixels);
CGFloat sizeOfTiles = ((max < 512.0f) ? 512.0f : 1024.0f);
tiledLayer.tileSize = CGSizeMake(sizeOfTiles, sizeOfTiles);
tiledLayer.frame = CGRectIntegral(CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFCropBox));
[[self layer] addSublayer:tiledLayer];
[self setNeedsDisplay];
But I am facing two problems here:
If pdf1 is not loaded completely and I add another pdf2 on top of it then pdf1 will never be loaded completely. It will be blurred.
If pdf1 is loaded completely, then on adding pdf2 and zooming after zooming 3,4 times, pdf1 becomes blurr.
Please help!!