Using PDF on iPad

Has anyone tried using PDF in an iPad application using the CGPDf features. I used it on the iPhone and it works fine, but when I use the same code on the iPad, the page is reduced in size, after trying out I set the scale as follows

CGContextScaleCTM(context,1.85, -1.80); 

This time it is perfect for the screen, but it was just trial and error, why it is not suitable for the screen, as in the iPhone, I also set the size of the view correctly.

Anyone who knows about this, let me know.

and also this is my drawRect method, where I draw a 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

+4
source share
2 answers

Do you 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 PDF size.

+8
source

if you have a navigation bar, it will leave about 10 pixels on both sides .. it will only fit if you draw the entire area (768 * 1004) ..

0
source

Source: https://habr.com/ru/post/1306553/


All Articles