How-to use in existing projects

We assume that you've cloned and that you are using Xcode 4.

This tutorial is available as screencast on YouTube. You should take a look!

  • Open the existing project in Xcode.
  • Press ⌘, and open Xcode preferences, choose the Source Tree icon. Add FASTPDFKIT_DIR variable pointing to the folder on your hard drive containing FastPdfKit.
  • Drop FastPdfKit Sample.xcodeproj from the Finder to the left project bar.
  • From FastPdfKit Sample project (now added as workspace) and the Other Sources group, drag & drop the FastPdfKit.xcconfig file to the existing project.
  • Select the Project and then in central bar the Project again, then in the Info tab in configurations click on triangles on the left of your Debug, Release, etc and then choose FastPdfKit as configuration files.
  • Select the Target and in the Build Phases, Target Dependencies row and add FPKReaderLib.
  • Now drag & drop the FPKReaderBundle.bundle from Resources group to the existing project.
  • In the Other Sources group you'll find the Snippets.strings document with few rows of code to open a pdf. Use them in your controller as specified below.
  • Choose or add a new controller (we will call it LauncherController) to manage pdf documents and in the .h file add and add lines 3 and 7 to the controller

       //  LauncherController.h
       #import <UIKit/UIKit.h>
       @class MFDocumentManager;
       @interface LauncherController : UIViewController {
  • Add this code before the @implementation line in the .m file

       #import "MFDocumentManager.h"
       #import "ReaderViewController.h"
  • Implement at least this method in the .m file

       //  LauncherController.m
          /** Set document name */
          NSString *documentName = @"Manual";
          /** Get temporary directory to save thumbnails */
          NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
          /** Set thumbnails path */
          NSString *thumbnailsPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",documentName]];
          /** Get document from the App Bundle */
          NSURL *documentUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:documentName ofType:@"pdf"]];
          /** Instancing the documentManager */
          MFDocumentManager *documentManager = [[MFDocumentManager alloc]initWithFileUrl:documentUrl];
          /** Instancing the readerViewController */
          ReaderViewController *pdfViewController = [[ReaderViewController alloc]initWithDocumentManager:documentManager];
          /** Set resources folder on the manager */
          documentManager.resourceFolder = thumbnailsPath;
          /** Set document id for thumbnail generation */
          pdfViewController.documentId = documentName;
          /** Present the pdf on screen in a modal view */
          [self presentModalViewController:pdfViewController animated:YES]; 
          /** Release the pdf controller*/
          [pdfViewController release];
  • Now call the above action to open the pdf.

Within FastPdfKit project there are many other sample classes, where you can find methods (heavily commented) to manage every feature.

FastPdfKit Sample includes also a library and a bundle of a kiosk implementation. Just include also the FPKKioskLib and FPKKioskBundle.bundle.