Need help with MTPDF?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

207 Stars 28 Forks MIT License 30 Commits 4 Opened issues


Objective-C PDF objects. Doing my part to help us stay out of the headache that is Core Foundation.

Services available


Need anything else?

Contributors list


Objective-C PDF objects. Doing my part to help us stay out of the headache that is Core Foundation.

A Swift port


In your Podfile, add this line:

pod "MTPDF"

pod? =>

NOTE: You may need to add

to "Other Linker Flags" in your targets build settings if the pods library only contains categories.

Example Usage

Read a PDF from a file:

MTPDF *pdf = [MTPDF PDFWithContentsOfFile:path];
pdf.pages.count       // => 3
pdf.isEncrypted       // => NO
pdf.title             // => @"Forever Young"

Read a PDF from a URL:

MTPDF *pdf = [MTPDF PDFWithContentsOfURL:url];

Create a PDF from data:

MTPDF *pdf = [MTPDF PDFWithData:data];

Modify A PDF:

MTPDF *pdf = [MTPDF PDFWithContentsOfURL:url];
pdf.title   = @"New Title";  = @"New Author";
pdf.creator = @"New Creator";
pdf.subject = @"New Subject";

Write PDF to file:

[pdf writeToFile:file];

Iterate through pages:

for (MTPDFPage *page in pdf.pages) {
  page.size     // => (500, 600)

Draw a page in a UIView drawRect (fitting the height of the view):

MTPDFPage *page = pdf.pages[0];

// Calculate the size to draw based on the height of the view's rect CGSize fullSize = page.size; CGFloat ratio = fullSize.width / fullSize.height; CGSize aspectFittingSize = CGSizeMake(rect.height * ratio, rect.height);

CGContextRef context = UIGraphicsGetCurrentContext();

[page drawInContext:context atSize:aspectFittingSize];

Draw a page to a CGPDFContext:

MTPDFPage *page = pdf.pages[0];
CGRect rect = page.frame;
CGContextRef PDFContext = CGPDFContextCreateWithURL((__bridge CFURLRef)([NSURL fileURLWithPath:destinationFilePath]), &rect, NULL);

[page drawInPDFContext:PDFContext];


Export a page as an UIImage:

UIImage *img = [page imageWithPixelsPerPoint:4];

This allows you to export the PDF at whatever resolution you need. Keep in mind, whatever the pixels per point is, the width and height will grow by that factor from the original size.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.