What to do when creating a PDF crashes your iOS device.

If you create PDF’s using the iOS SDK, and UIKit as mentioned in my previous post, you may find that while the PDF’s generate perfectly on the simulator, they crash your app on a real device. The reason it works on the simulator and not on the iOS device, usually has something to do with how much memory each has. The simulator has as much as your development machine, while the iOS device has… well, considerably less.

If you find your app crashing, what I’ve found helps the most is slicing your large images into smaller images to remove the whitespace in your images. When you create a PDF using UIKit, each image is loaded into memory as RGBA to be pasted into the PDF. If you’re using the x4 method to get high resolution PDF’s, that means a full page ‘background’ would take up almost 8 MB. Much of this is waste, since you’re probably going to have quite a bit of whitespace.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *