PDF Navigation
Page Navigation
After loading a PDF document, you can programmatically interact with it, which allows you to scroll to different pages or destinations. All of the interaction APIs are available on CPDFView
- CPDFView::goToPageIndex:animated:
- CPDFView::goToDestination:animated:
- Goes to the specified rectangle on the specified page, use function CPDFView::goToRect:onPage:animated:
This allows you to scroll the CPDFView object to a specific CPDFAnnotation or CPDFSelection object, because both of these objects have bounds methods that return an annotation or selection position in page space.
Note: This method’s rect is specified in page-space coordinates. Page space is a coordinate system with the origin at the lower-left corner of the current page.
Outline
Outline allows users to quickly locate and link their point of interest within a PDF document. Each outline contains a destination or actions to describe where it links to. It is a tree-structured hierarchy, so function CPDFDocument::outlineRoot
must be called first to get the root of the whole outline tree before accessing the outline tree. Here, “root outline” is an abstract object which can only have some child outline without next sibling outline and any data (includes outline data, destination data and action data). It cannot be shown on the application UI since it has no data. You can also use function CPDFDocument::setNewOutlineRoot
to create a new root outline.
After the root outline is retrieved, the following functions can be called to access other outline:
- CPDFOutline::parent
- To access the child outline.
- (NSArray *)childOutline:(CPDFOutline *)outline {
NSUInteger numberOfChildren = [outline numberOfChildren];
NSMutableArray *child = [NSMutableArray array];
for (int i=0; i<numberOfChildren; i++) {
[child addObject:[outline childAtIndex:i]];
}
return child;
}
- CPDFOutline::insertChildAtIndex:
- CPDFOutline::removeFromParent
- CPDFOutline::insertChild:atIndex:
. When moving items around within an outline hierarchy, you should retain the item and call CPDFOutline::removeFromParent
first.
Bookmarks
Since each bookmark is associated with a specific page, it provides the ability to link to a different page in a document allowing the user to navigate interactively from one part of the document to another.
- CPDFDocument::bookmarks
- CPDFDocument::bookmarkForPageIndex:
- CPDFDocument::addBookmark:forPageIndex:
- CPDFDocument::removeBookmarkForPageIndex: