PDF page height and width

I want to get the height and width of a PDF page in my application. How to do it?


source to share

2 answers

you can get it this way

float width = CGPDFPageGetBoxRect(pdfPageRef, kCGPDFMediaBox).size.width;
float height = CGPDFPageGetBoxRect(pdfPageRef, kCGPDFMediaBox).size.height;




If you have PDFDocument document

you can get the page:

PDFPage *page = [document pageAtIndex:pageIndex];


Based on Vignesh's answer, you can do the following with a page:

CGFloat pageWidth = CGPDFPageGetBoxRect(page.pageRef, kCGPDFMediaBox).size.width;
CGFloat pageHeight = CGPDFPageGetBoxRect(page.pageRef, kCGPDFMediaBox).size.height;




All Articles