Is there any way to determine the total number of pa开发者_开发问答ges once the pdf file is loaded in the ipad? I am using CATiledLayer Method for loading the pdf file.
Thanking you.
Call the function size_t CGPDFDocumentGetNumberOfPages(CGPDFDocumentRef document);
See the CGPDFDocument documentation for other useful stuff you will probably need.
CFURLRef url = CFURLCreateWithFileSystemPath (NULL, (__bridge CFStringRef)[NSString stringWithFormat:@"%s",filePath], kCFURLPOSIXPathStyle, 0);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(url);
CGPDFPageRef myPageRef = CGPDFDocumentGetPage(pdf, 1);
int totalPages= CGPDFDocumentGetNumberOfPages(pdf);
Okay Thanks Altealice.I implemented in this manner and i am able to find the number of pages.
Using the following code:
NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"mypdf" ofType:@"pdf"];
NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
size_t pageCount = CGPDFDocumentGetNumberOfPages(document);
精彩评论