Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple UIImage+PDF renderer category for iOS scalable assets
Objective-C
branch: master

This branch is 1 commit ahead, 49 commits behind mindbrix:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Demo
PDFExample.xcodeproj
.DS_Store
.gitignore
PDFView.h
PDFView.m
README.md
UIImage+PDF.h
UIImage+PDF.m

README.md

UIImage+PDF

UIImage+PDF provides a UIImage class category method to render a UIImage from any PDF stored in the application bundle. The motivation for this was to enable the easy use of scaleable vector assets in iOS apps.

Usage

Add the sources files in the UIImage+PDF sub folder to your project. Use the following line to import the necessary methods.

#import "UIImage+PDF.h"

Then simply call the UIImage class method as shown here:

UIImage *img = [ UIImage imageWithPDFNamed:@"YingYang.pdf" atSize:CGSizeMake( 40, 40 ) ];

An example project is included in this repository. The important code is in viewDidLoad: in UIImage_PDF_exampleViewController.m.

PDF file size

By default Adobe Illustrator saves exported PDFs very inefficiently. For best results, export in EPS format, load this into Preview and then save as a PDF. The included example file YingYang.pdf shrunk to 10% of its original size with this workflow.

Other vector graphics editors which natively use the OSX Quartz renderer, such as Sketch, will create much more compact PDFs.

Something went wrong with that request. Please try again.