Multimedia Overlays


FastPdfKit is a framework to add PDF support to iOS apps and it's available here on github.

This document is the Readme for the multimedia sample project available on github.

Since version 3.0 it supports multimedia overlays from native pdf annotations.

In this repository we are creating some sample classes to let you familiarize yourself with the their capabilities and to help you create your customized overlays.

Default FastPdfKit annotations

FastPdfKit supports internally some annotations, take a look at this list.

Custom pdf uri annotations

With the technique illustrated below you can create any kind of overlay:

  • Show maps
  • Show movies
  • Show web pages
  • Add sounds
  • Image gallery
  • Popup messages
  • Popup web view
  • Pupup images
  • Include pools
  • Get more informations
  • Interact with the document
  • Set some properties
  • Lock the rotation
  • Tweet some text
  • 360° panorama
  • Video popup
  • Change page content
  • Images carousels
  • Send email
  • ...

Download the FastPdfKit Reader app from the App Store and look at the Gliphit pdf: it doesn't seems a pdf!

You can use the FastPdfKit Reader app to get inspiration for your custom overlays. Here there is the complete annotation parameters supported.


In the MFViewController the method actionOpenPlainDocument instantiates all the classes.

For the pdf visualization we are using a ReaderViewController subclass called ReaderViewControllerSubclass.

To manage the overlay we've created an object that implements the FPKOverlayViewDataSource protocol called OverlayDataSource.

Then we have two classes MFMapAnnotation and YouTubeView to customize the overlay appearances.


The Protocol requires the three methods:

- (NSArray *)documentViewController:(MFDocumentViewController *)dvc overlayViewsForPage:(NSUInteger)page;

This method should return an array of views to be rendered over each page.

- (CGRect)documentViewController:(MFDocumentViewController *)dvc rectForOverlayView:(UIView *)view onPage:(NSUInteger)page;

This method should return the CGRect for each annotation required to manage rotations and single/double page.

- (void)documentViewController:(MFDocumentViewController *)dvc willAddOverlayView:(UIView *)view;

This last method let you perform some operations when the annotations are going to be displayed. By default FastPdfKit adds a fade-id and fade-out alpha animation on every added view.


You have at least two ways to manage overlay sources: use the native pdf uri annotations or some external overlay data source.

In this example we are using standard pdf annotations.

With the MFDocumentManager's method - (NSArray *)uriAnnotationsForPageNumber:(NSUInteger)pageNr we are obtaining an array of FPKURIAnnotation with two properties: (NSString *) uri and (CGRect) rect.

The uri property will contain the full uri of the annotation created with Preview (or any other pdf editor). The rect is filled with page coordinates of the pdf annotation.

Uri with Preview

The goal is to create a view that will use these informations to represent any content.

With the array of annotations from the pdf we call the custom method

- (UIView *)showAnnotationForOverlay:(BOOL)load withRect:(CGRect)rect andUri:(NSString *)uri onPage:(NSUInteger)page;

to parse the uri parameters and create the UIView.


The first lines are needed to parse the uri, splitting it in protocol (the part before ://), resource (the part between :// and ?) and parameters (after ? separated by &).

Protocol, resource and parameters are useful to define different overlays.

In the sample project we are supporting:

  • utube://
  • map://
  • goto://

with many parameters listed at the end of this document.

For YouTube support we've created a UIWebView subclass called YouTubeView that contains just the embedded player.

In an if block we check with the load boolean value if the method is called when the page loads or when the user has tapped on the annotation. In this case we are interested to show the YouTube player immediately.

Then we instantiate the YouTubeView with movie id taken from the annotation uri.

if ([uriType isEqualToString:@"utube"]){            
    if (load){
        YouTubeView *youTubeView = [[YouTubeView alloc] 
              initWithStringAsURL:[NSString stringWithFormat:@"", uriResource]
              frame:[documentViewController convertRect:rect toViewFromPage:page]];
        retVal = youTubeView;


The frame of the annotation is calculated from the one extracted from the pdf annotation and converted to UIView coordinate system.

To do that we are using the MFDocumentViewController's convertRect:toViewFromPage:.

The very same frame should be passed when the view is created and in any moment the MFDocumentViewController calls the rectForOverlayView:onPage: method.

YouTube Video

An overlay with a web view that contains the youtube player. The video id is something like npawmHVaf-E and you can take it from any YouTube video



Google map with overlay with multitouch and that redraws based on the zoom page level of the pdf itself.

The resource is the map type.



  • Latitude


  • Longitude


  • Span latitude


  • Span langitude


Optional parameters

  • Pin latitude


  • Pin longitude


  • Pin title


  • Pin subtitle


  • Pin color


  • Add user position




Zoom on a page

Choose a page and the area where you want to zoom to.



  • Page destination


  • Zoom level


  • Origin x of the area


  • Origin y of the area


  • Width of the area


  • Height of the area


Follow us

Recent Discussions

15 Apr, 2020 04:25 AM
26 Feb, 2020 07:23 AM
27 Jun, 2019 06:08 AM
23 Nov, 2018 01:54 PM
14 Nov, 2018 04:37 PM