Has Anyone tried using PDF in iPad Application, using CGPDf functions. I have used this in iPhone and it works perfectly , but when i use the same code in iPad , the Page are Shrunk in size, after a try outs i set the Scale as follows
CGContextScaleCTM(context,1.85, -1.80);
This time the it fits the screen perfectly , but that was just a trial and error , why does it not fit the screen as in iPhone, i have set the view size correctly too.
Anyone having a clue about it please let me know.
and also this is my drawRect method where i am drawing the PDF page
void drawRect:(CGRect)rect{
UIGraphicsBeginPDFPage();
CGContextRef context = UIGraphicsGetCurrentContext();
CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber);
CGContextSaveGState(context);
CGContextTranslateCTM(context, 1.0, self.frame.size.height);
CGContextScaleCTM(context,1.0, -1.0);
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
}
alt text http://www.freeimagehosting.net/uploads/6b8bb69bb9.png
Thanks
You'll want to do something like
CGRect box = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
CGFloat scale = bounds.size.width / box.size.width;
if (bounds.size.height / box.size.height < scale)
scale = bounds.size.height / box.size.height;
to adapt to the PDF's size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With