CGPDFDocument scaling
<p>I am just starting to build an app that will display PDF documents. I've been experimenting, subclassing UIView and using the code from Apples demo. I have a PDF document that contains an image that is 1024 x 748 pixels at 131 ppi, so that it SHOULD fill the iPad screen in landscape view.</p>

<p>When I run the app the pdf is scaled to approximately .25% of its full size, centered in the iPad screen. Why isn't the PDF being displayed full sized? </p>

<p>Code from my custom UIView:</p>

<pre>
<code>
-(id)initWithFrame:(CGRect)frame PDFName:(NSString *)pdfName
{
    self = [super initWithFrame:frame];
    if(self != nil)
    {
        self.backgroundColor = [UIColor blueColor];
        self.opaque = YES;
        self.clearsContextBeforeDrawing = YES;

        CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)pdfName, NULL, NULL);
        pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
        CFRelease(pdfURL);
    }

    return self;
}


- (void)drawRect:(CGRect)rect {

    // PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
    // before we start drawing.
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);

    // Grab the first PDF page
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);

    // We're about to modify the context CTM to draw the PDF page where we want it, so save the graphics state in case we want to do more drawing
    CGContextSaveGState(context);
    // CGPDFPageGetDrawingTransform provides an easy way to get the transform for a PDF page. It will scale down to fit, including any
    // base rotations necessary to display the PDF page correctly. 
    CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, self.bounds, 0, true);
    // And apply the transform.
    CGContextConcatCTM(context, pdfTransform);
    // Finally, we draw the page and restore the graphics state for further manipulations!
    CGContextDrawPDFPage(context, page);
    CGContextRestoreGState(context);

}

</code></pre>
