I am using a quartz library. I am drowing pdf page image using layer in uiview. but i thought while draw an image its does not fit to page in screen. I am giving my code as given below.
-(void)loadPdf:(int)pageno{
myPageRef = CGPDFDocumentGetPage(myDocumentRef, pageno);
CGRect pdfcropBox = CGPDFPageGetBoxRect(myPageRef,kCGPDFCropBox);
CGRect pdfcropBox1;
pdfcropBox1.origin.x=0;
pdfcropBox1.origin.y=0;
pdfcropBox1.size.width=scrrollPotrait.frame.size.width;
pdfcropBox1.size.height=pdfcropBox.size.height;
CATiledLayer *tiledLayer = [CATiledLayer layer];
tiledLayer.delegate = self;
tiledLayer.tileSize = CGSizeMake(1024, 1024);
tiledLayer.levelsOfDetail = 10;
tiledLayer.levelsOfDetailBias = 2;
tiledLayer.frame =self.view.frame;
CGRect pageScrollViewFrame = CGRectMake(((pageno - 1) * scrrollPotrait.frame.size.width), 0, scrrollPotrait.frame.size.width, scrrollPotrait.frame.size.height);
pageScrollView = [[UIScrollView alloc] initWithFrame:pageScrollViewFrame];
[pageScrollView setTag:pageno];
[pageScrollView setDelegate:self];
[pageScrollView setMinimumZoomScale:1.0];
[pageScrollView setMaximumZoomScale:6.0];
[pageScrollView setClipsToBounds:NO];
[pageScrollView setContentSize:CGSizeMake(scrrollPotrait.frame.size.width * 1, scrrollPotrait.frame.size.height)];
UIView *myContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scrrollPotrait.frame.size.width,scrrollPotrait.frame.size.height)];
[myContentView.layer addSublayer:tiledLayer];
[myContentView setContentMode:UIViewContentModeScaleToFill];
UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleDoubleTap)];
singleFingerDTap.numberOfTapsRequired = 1;
[myContentView addGestureRecognizer:singleFingerDTap];
[singleFingerDTap release];
[pageScrollView addSubview:myContentView];
UITapGestureRecognizer *singleFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
singleFingerDoubleTap.numberOfTapsRequired = 2;
[myContentView addGestureRecognizer:singleFingerDoubleTap];
[singleFingerDoubleTap release];
[scrrollPotrait addSubview:pageScrollView];
[myContentView release];
}
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx, myPageRef);
}
in viewdidload I initialized scroll view as given below
scrrollPotrait.contentSize = CGSizeMake(scrrollPotrait.frame.size.width * totalPages, scrrollPotrait.frame.size.height);
scrrollPotrait.showsHorizontalScrollIndicator = NO;
scrrollPotrait.showsVerticalScrollIndicator = NO;
scrrollPotrait.scrollsToTop = NO;
scrrollPotrait.minimumZoomScale = .1;
scrrollPotrait.maximumZoomScale = 1.0;
scrrollPotrait.delegate = self;
I would like to my pdf page should be set to in width. if it is in any size. please give me a hint or regarding document related that.
thanx in advanced.