iPDFdev Tips & Tricks for PDF development


Meet Sorin Nistor

I work as a senior software developer for O2 Solutions, a software company that develops PDF tools and components for Microsoft .NET framework. I have been involved from the start in the development of the main company products, PDF4NET - a .NET library for creating and editing PDF files and PDFView4NET - a .NET toolkit for displaying and printing PDF files.
I've been working with PDF files for 9 years, the PDF specification is my professional bible πŸ™‚
During the last months I started to investigate the PDF capabilities of the iOS platform, and while the available PDF API is pretty rich, it requires quite a good knowledge of PDF specification in order to take full advantage of it.
This blog wants to bring together the iOS PDF API and the PDF specification by presenting solutions to specific problems iOS developers encounter when working with PDF files.
Let me know if it succeeds.
You can contact me by posting a comment below or by email at ipdfdev [at] ipdfdev [dot] com.

Licensing information

Code samples quoted on each blog page and linked projects may be used in accordance with the following "zlib"-style license:

Copyright (c) 2011 Sorin Nistor. All rights reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

This permission only applies to the code samples and code in the downloadable projects. The prose and artwork assets of this blog and its downloadable content may not be reproduced without prior consent.

Comments (58) Trackbacks (0)
  1. Hello Sorin,

    I manage an iPad HTML/PDF “viewer” application for my company and am investigating the availability of APIs/SDKs that will allow for the addition of a PDF annotation capability. Can you suggest any products?


    • I assume you developed the viewer using the CGPDF API. The problem with this approach it that at some moment in time you’ll have the PDF file loaded twice in memory, once in your viewer and once in the other library where you annotate the file. With large files there might be memory problems. It is a pity that Apple does not support PDF modification using the CGPDF API. Regarding annotations there is libharu but I’m not sure it can load existing PDF files. There are also the toolkits from Foxit and PDFTron, but they can be pretty expensive. I’m working myself on an Objective-C library for editing PDF files on iOS but it will be ready only during September.

  2. Hi there,

    I love all the work you have done with PDF’s. I was wondering if you could help me. Please keep in mind I have a basic knowledge of xcode just from exploring. I am a teacher and would love for my students to present certain aspects of their work they create in .doc .pdf .xls in xcode. Do you have any projects which use .xib or storyboards that would make it easy for my students (who are 12yo) to create their own backgrounds, colour, and simple buttons that link to PDFs, DOC and XLS? Any help would be much appreciated.

    Something along the lines of a front page that consists of buttons which link to certain files with extensions pdf doc and xls. Ive tried using your revised zoomingpdf project and uiwebview but not sure how to load more than one file in the uiwebview.

    Thank you again for your tutorials and source codes.



  3. Is the library available (iOS SKD)? Does it support form fields? I need to generate a pdf with form fields that can be manipulated (i.e. data in them edited).

    • The library is not available, it is just at the beginning. In the end it will support form fields (add/remove form fields and fill the fields) but at this moment I do not know when this feature will be available.

  4. I am trying to extract images from a pdf using your example code, and cannot find where PDFContentStreamProcessor and PDFGraphicsState is declared. My pdf has many pages, each page is a single full (page) size image.

  5. Hey iPDFdev,
    Love your blog and the various articles you have here that allow people to get educated with PDF products.
    I was wondering if you knew about the PDF product that is available on Binpress?

  6. Hi Sorin,

    Congrats on this awesome work. Very informative.
    Since a long while I have been looking for a PDF framework for ios which supports RTL paging and Arabic search.
    Despite on what they claim I was never able to find a reliable one.
    Out of your experience and expertise, could you indicate me one or more good options.


  7. Does it support CCITT G4 compression? I would like to import CCITT G4 images into a PDF.

    Let me know


  8. RIght now to get the TIFF we are doing something like this:

    CFDataRef tiffFaxG4DataForCGImage(CGImageRef cgImage) {
    NSBitmapImageRep *imageRep =
    [[[NSBitmapImageRep alloc] initWithCGImage:cgImage] autorelease];
    NSData *tiffData =
    [imageRep TIFFRepresentationUsingCompression:NSTIFFCompressionCCITTFAX4
    return (CFDataRef) tiffData;

    Let me know when you are getting close


  9. NSBitmapImageRep claims to be able to generate a CCITT FAX Group 4 compressed TIFF

    • Yes, but what I have to do is to decode the tiff image, get the image data, re-encode it using CCITT G4 and put it in the PDF. Simply taking the CCITT G4 data from the TIFF and put it in the PDF does not always work.

  10. Hello
    I would like to know if with this framework I can open an existing PDF and add something like a jpg image (tipically a stamp or a note). Thanks

    • This feature will be available in about 2 months. I’m working on parsing PDF files and when this feature will be implemented you will be able to load a PDF file and add new content (vector graphics, text, images, annotations, etc) to it.

  11. Hi Surin, thanks for demystifying a little bit the PDF internals and make it become so accessible. I had a look at the sample code. Very nice! I am working on a PDF Annotator on Mac OS X. It might be similar to what you are working on as per your message of Feb 28th except that I do not touch the PDF Stream itself, but on only draw additional graphics myself. The additional graphics can be drawn before page rendering in which case it goes to the background or after the rendering so it be superimposed on the foreground.

    I realized that some PDF documents have an opaque white background on each page, specially those created using -[NSView dataWithPDFInsideRect]. So that those of my graphics in the background becomes hidden. I need a way to detect when the PDF stream contains this white page background color in order to move all my graphics in the foreground. Can this white background be detected as an image or which operator do I need to implement for that?

    Thank you vera much!


    • This white background can be created in many ways (an image, a rectangle, etc), it is not some standard object in PDF. It is not something that can be reliably detected and removed.

  12. Hi Sorin,
    Is it possible to edit an existing PDF with your framework? If yes, could you send me an example please?

    Thank you very much


  13. Your sample is not working in Xcode 6.1, do you have any working sample?

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

  14. Hi Sorin,

    Where can i find the framework for OSX ?
    Would like to do dome testing .



    • I’ll send it to you by email.

      • Hello Sir,

        I am interested in this for OSX platform, would like to offer myself for testing,

        Just developed scanner application with pdfkit for viewing, was looking for OSX PDF framework that would support these two things (form fields just like mail merge MS in word) once we run auto form fill fields, give the user option to edit the pdf text.

        If you could send me the kit by email, and some instruction will integrate in my application, and test it out.

        Vijay Meganathan

  15. Hi Sorin,

    I stumbled upon your framework and I am impressed by the functionality. Also it seems to have the most convenient API of all PDF creation frameworks available.

    Is it possible with your framework to draw an image with a specified color space (e.g. ICC)? Or would I need to do the color space conversion myself before drawing it?
    Or more generally asking, how are colorspaces of images handled in the PDF specs?

    Will this framework be updated? I noticed that the framework does not contain a slice for arm64 architectures yet.

    • At this moment I’m using the CoreGraphics API to decode the images and the image data is always embedded as RGB. In the future I’ll add support for creating images with custom color spaces.
      Right now I’m restarting the development, I’m working to support 64bit and ARC.

      • Thanks for this info! I appreciate it.
        Great to hear that you’re working 64bit support.

        Do I assume correctly, that it is not possible to embed images with custom color spaces with the CoreGraphics API alone?

        May I ask if you can already tell when 64bit support and support for custom color spaces will come?

  16. Hi, Sorin

    We are working an mobile App which requires following functions:

    1. Load existed pdf from server to ipad (or iphone)
    2. edit the pdf (usually just filling in the form, adding image to the pdf etc.)
    3. save the filling data into the server. (database)

    can you please let me know if your sdk can finish above function?

    thank you so much.

  17. Hi,

    I am interested in the IFXPDFFactory.

    From the demo project, I found it just create the pdf file from an empty page and then add some annotation. Is it able load an existing pdf file?


  18. Hi,

    I am interested in purchasing a license of the IFXPDFFactory.

    Can it create a PDF from a view controller?
    Can it create a PDF from HTML?

    I found it very awkward to create PDFs the Apple iOS built-in way…


  19. What I mean is an easy way to create a PDF from that what the user sees of my app in his iPad.
    Let’s say the app is a calculator for financial loans. So the user fills out a couple of screens/view controllers and from that information a loan proposal is calculated. The calculated loan and all the user input is finally presented to the user in a view controller.
    I am looking for simple way to print that out/save it to a PDF file, without me having to create that what is basically a with data populated storyboard.

  20. Hi Sorin-

    I’m considering a license and was wondering if you had finished the ability to insert an existing PDF into a document. I was also wondering if there is a way to use attributed text.

    Thanks for the work- looking forward to hearing back.

  21. Hello again Sorin-

    I’m looking at your sample code and getting memory leaks with Instruments- I am very interested in purchasing a license, however I’m curious about the leaks and my previous questions.

    Can you let me know?


  22. Thanks Sorin- I will watch here for the 1.0 release. Thanks for the work.

  23. Hello,

    I user your code for convert image to pdf. Its woking fine for single page pdf. But i need to create multiple page pdf from array of image. Can you please give me solution for it.

    Thanks in advance…..

  24. Hi! I am interested in an ios app that utilizes your code. Specifically, PDF optional content toggling. Do you know of one?

    I need to be able to toggle on/off different layers on top of a floorplan drawing. Any info is appreciated!

Cancel reply

No trackbacks yet.