Question

When viewing a PDF file, QuickView can show the individual pages. Can this be done with MS Office files too (DOC, PPT)? I want a way to know how many pages/slides are in the document and what page I am currently viewing.

Thanks for the help!

Was it helpful?

Solution

The result of CGPDFDocumentGetPage is the same as an indirect page reference you get when resolving a destination in an outline item. Both are essentially dictionaries and you can compare them using ==. When you have a CGPDFDictionaryRef that you want to know the page number of, You can do something like this:

CGPDFDocumentRef doc = ...;
CGPDFDictionaryRef outlinePageRef = ...;
for (int p=1; p<=CGPDFDocumentGetNumberOfPages(doc); p++) {
  CGPDFPageRef page = CGPDFDocumentGetPage(doc, p);
  if (page == outlinePageRef) {
    printf("found the page number: %i", p);
    break;
  }
}

An explicit destination however is not a page, But an array with the first element being the page. The other elements are the scroll position on the page etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top