iOS
ComPDFKit PDF SDK
Guides

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.

 

Scrolls to the specified page, use function CPDFView::goToPageIndex:animated:.

Goes to the specified destination, destinations include a page and a point on the page specified in page space, use function 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:

 

To access the parent outline, use function 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;
}

 

To insert a new outline, use function CPDFOutline::insertChildAtIndex:.

To remove an outline, use function CPDFOutline::removeFromParent.

To move an outline, use function 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.

 

To access bookmarks, use function CPDFDocument::bookmarks.

To access a bookmark for page, use function CPDFDocument::bookmarkForPageIndex:.

To add a new bookmark, use function CPDFDocument::addBookmark:forPageIndex:.

To remove a bookmark, use function CPDFDocument::removeBookmarkForPageIndex:.