I have attached a piece of code that I use to display a PDF. The following code displays the PDF, but it seems to be either compressed or not using the full screen size of the iPad, making the page too small.
How can I display a PDF file that is on the edge of the iPad screen or in an enlarged state? I tried to use a different approach (approach-2), but this creates a problem with the appearance of a PDF file at an angle of 90 degrees.
Approach-1:
CGContextSaveGState(ctx); CGContextTranslateCTM(ctx, 0.0, [self.view bounds].size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, [self.view bounds], 0, true)); CGContextDrawPDFPage(ctx, page); CGContextRestoreGState(ctx);
Approach-2:
CGPDFPageRef page = CGPDFDocumentGetPage(pdfdocument, PageNo+1); if(page){ CFRetain(page); } CGRect pageRect =CGPDFPageGetBoxRect(page, kCGPDFMediaBox); int angle= CGPDFPageGetRotationAngle(page); float pdfScale = self.bounds.size.width/pageRect.size.width; CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0); CGContextFillRect(context,self.bounds); CGContextSaveGState(context);
Can someone suggest me a solution that allows any PDF file of any size and any angle to be displayed in full screen on the iPad in both orientations? It would be great if you provided me with a code snippet or pseudo code. Thanks
source share