Category Archives: Apple

As I wrote recently, the ability to create a PDF document from an application’s printed content is one of my favorite features that Apple added in iOS 9. This feature leverages the printing system so that if your application can print, a user will also be able to use the new “Save PDF to iBooks” feature. Well, almost.

The key is that your application needs to offer printing by using Apple’s “Share Sheet”, instead of using the older method of using a UIPrintInteractionController. And unfortunately, as of my writing this, all of Apple’s sample code demonstrating how to implement printing in an iOS application uses the UIPrintInteractionController method of presenting printing to the user.

I ran into this recently when I emailed the developers of one of my favorite iOS applications and suggested they add support for the “Save PDF to iBooks” to their app. After all, the app already supported the Share Sheet for a number of tasks other than printing but it supported printing using the old UIPrintInteractionController. The developer was kind enough to reply to my suggestion with interest, but the response I got was: “I’d like to but I don’t know how to do that.”

Poking around Apple’s developer site, I found the handy page AirPrint for Developers. It includes a link to the 2014 WWDC session on AirPrint (there was none in 2015) which is a great presentation with tons of info for app developers getting started with printing on iOS. And the AirPrint for Developers page has four links to sample code that implement printing in various ways. Unfortunately none of these samples implement the Share Sheet method of printing.

So I grabbed one of Apple’s samples and updated it. I started with one that I myself wrote (long ago) at Apple. It demonstrates how to print content from a WebView in both a basic way and also by using some fancier techniques to add more control to the layout of content on the printed pages. Updating it to use the Share Sheet is pretty straightforward.

The only substantive change needed to make the sample app use the share sheet is to take out the use of the UIPrintInteractionController from the sample and replaced it with the use of a UIActivityViewController. This controller takes an array of “Activity Items” as part of its initialization. When the controller is presented it determines what activities (or actions) can be taken on those activity items and allows the user to choose from those actions.

The UIActivityViewController determines that printing is a supported activity if the activity items array contains both an object of the UIPrintInfo class and also a source of print data. The source of print data can be a printing item or items (e.g. a photo or photos), a UIPrintFormatter object, or a UIPrintPageRenderer subclass. For the original sample code, the source of print data was a UIPrintPageRenderer subclass that the code created and assigned to the myRenderer local variable. For fun in the new code I also added an NSURL corresponding to the URL of the web page the user is visiting. This allows the Share Sheet to show more actions for the sample app than just those associated with printing. Once the UIActivityViewController is created, all that is needed is to present it and UIKit does the rest. I mostly stole the code to present the activity view controller from this sample.

Here’s the updated code snippet that replaces the old usage of the UIActivityViewController in the original sample:

Running the modified app on an iPad and touching the action icon brings up the Share Sheet instead of the Printing UI directly (as it would have if I’d not modified the original sample). From there you can see that both the Print icon as well as the “Save PDF to iBooks” icon appears on the Share Sheet. And both behave as expected!

If you’ve already got printing working in your app, now’s the time to update to using the Share Sheet method instead of the older method. Without a lot of extra work on your part, users get a great new option to save your application’s content in a print ready format. And if you’ve not added printing to your application to date, the “Save PDF to iBooks” feature provides yet another reason to do so.

New in iOS 9 is the ability to save web pages as a PDF document to iBooks. It is a feature that is near and dear to my heart, in part because it is the last major feature I worked on at Apple before I left in early 2013.

What users of iOS 9 may notice is that Safari offers a new item in the Share Sheet: “Save PDF to iBooks”. They may think of this as a Safari specific feature.

But the Photos app also allows this, as will every iOS app that presents printing using the iOS “Share Sheet” (in iOS programming parlance, using an ActivityViewController). If an app can print via the Share Sheet then “Save PDF to iBooks” automatically appears as well.

During my career at Apple I worked primarily on the printing subsystems of Mac OS X and iOS. Much of that work was on the software plumbing needed for users to print on paper. But a portion of that work was enabling the ability to produce a PDF file corresponding to what otherwise would have been printed output. Save as PDF from the print dialog was part of OS X since version 10.0 shipped in 2001.

When creating the printing system for iOS, allowing for the ability to create a PDF reproduction of the results of printing was a goal of the design from the beginning. To me it seemed almost more important to allow users to capture content to store on their device to take with them (or email or whatever) than it was to produce pieces of paper. The design of the printing system allowed for it but the user facing feature was left out. So in the summer of 2012 I worked on an early implementation of what is now shipping. And I’m thrilled that it’s now out.

Executives at Apple talk about the desire to “surprise and delight our users”. Well I experienced that firsthand when I got a notification from Apple’s “Tips” app on my iPhone soon after updating to iOS 9. For me the (ironic) surprise was that the tips app was telling me about a feature that I worked on. And I was delighted to see that it was finally shipping.

I originally wrote this in January but thought I’d update it for the introduction of the first Retina iMac, especially since the original Mac and the Retina iMac are priced identically. It’s amazing to see how far the Macintosh hardware has come over the 30 1/2 years of its existence.

I never thought I’d be thanking Apple product marketing for something related to my book on programming Quartz graphics. Without their “help”, the book Programming with Quartz that I wrote with Bunny Laden would have been published without our names as authors. Instead it would have listed “Apple” as the author. But thanks to a cranky person in Apple product marketing, our names are there instead.

From the very beginning of the book project there was no question: our names would never be on the book. Apple had a firm policy, instituted by Steve Jobs when he returned as iCEO, that no individual names would be on Apple products, including any Apple publications. The author of our book would be “Apple” and our names would not appear in any form. There would be author bios on the back of the book but they would omit our names.

I should mention that our publisher, Morgan Kaufmann, had already done a number of books with Apple. They hated the fact that these books were published with “Apple” as the author and that the true author names were not known. To them it was extremely valuable to have real people’s names on their publications. But they wanted to do business with Apple and those were the terms.

Writing this book was my crazy idea, I started it with this understanding, and I had absolutely no problem with not having my name on it. I was writing this book for software developers use, not for personal glory. I was (and still am) passionate about the fact that 3rd party developers need good introductory and reference documentation and I was determined to do what I could to help provide that.

While our names weren’t going to be on the book, late in the project I had an idea how we could have an easter egg in the book so that we weren’t totally anonymous. After all, this was a book about graphics! In the chapter “Image Masking” there was a code sample and accompanying graphic that showed how to draw color through 1-bit image masks using Quartz. We needed images for the graphic so I thought we might take the opportunity to sneak us in.

By October 2005 we had finished the process of writing the book, dealing with copy- and proof-reading edits, processing the graphics, struggling with image rights issues, and handling a great many other details related to the book. The book was ready. The only thing remaining was to get final approval of the book’s cover from product marketing. Proposals for that artwork had been created by the publisher and the final selection had been made with the help of talented artists in Apple publications. This final approval seemed like a formality.

I can’t really tell what image is being used on the cover (blured drum stick?), but I don’t think this cover is really up to our standards. Is there someone in GD who can take a look and help out here?

No, that was not a “blured drum stick”, it was a crystal, a Quartz crystal. None of us could see the “blured drumstick”, even after drinking heavily (not really), taking massive quantities of drugs (not really), and more squinting than we thought possible (really). After we got this email everyone involved jokingly referred to the graphic on the cover as the “turkey drumstick”.

This helpful fellow high up in product marketing caused everything to come to a screeching halt. Of course we had been working with someone in GD (Graphic Design) and they were on board with the proposed cover. But this one person in product marketing was saying that this book had Apple’s name on it which made it an Apple product and in their opinion the cover reflected poorly on Apple.

At this point the publisher pushed back like crazy. They had a schedule for the book to be published and everything was ready. But now there was a huge roadblock that was holding things up. This was their design, so obviously they were happy with it. This was all an Apple problem. Should the design of the cover be done from scratch? How long was it going to take before “Apple” was happy with a new design? They had had plenty of previous experience with the lengthy process of getting things done with Apple.

Ultimately the proposed solution was to remove “Apple” as the author of the book and have the real author’s names appear. This would make product marketing happy since the book would no longer be an “Apple” product. The publisher was thrilled about this possible outcome. They definitely wanted our names on the book.

I don’t know for certain but I believe that Bertrand Serlet was the one to propose this solution to Steve Jobs. Amazingly Steve agreed to OK a one time exception to the Apple policy. (I would have loved to be a fly on the wall in that meeting!) The crisis was over and the book was published soon after.

Of course I was ecstatic about the result. It was totally unexpected and, as you can imagine, quite satisfying. I was extremely proud of the work I’d done on the book and was thrilled to have my name with Bunny’s on the cover. I still feel that way today, almost 9 years later.

Today it was announced that the Macworld print magazine is being discontinued and virtually all of the editorial staff is being let go. Even though I don’t personally know any of the people being laid off, other than a tiny amount through Twitter, I’m quite sad for them and for the magazine. And there is something personal about it for me also.

When the Mac was introduced in 1984, my life veered from a life studying physics and went into a totally different direction. (I wrote about this previously in some detail in my post 30 Years of Macintosh.) For young people in todays world it is almost impossible to imagine how we learned about this radical new computer. There was no internet as we know it today. No World Wide Web, no Twitter, no online blogs, no RSS feeds of news stories.

The way most of us found out information about the Macintosh was through the monthly publication Macworld. I remember eagerly awaiting each new issue. It was filled with tons of information that wasn’t available anywhere else. In the early days I read every word of every issue the same day it arrived. Every word. And the Macworld conferences were must attend shows and continued to be for more than 20 years. (I still get excited thinking about that Levco 68020 board that you could put in a Mac.)

I still have two issues from the early magazine. These issues made a difference in my life. I’ve kept them for 30 years and I’ll keep them for 30 more. Macworld ceasing publication seems personal. My heart goes out to those who’ve lost their jobs. And for the Apple community that has lost an old friend.

In 1984 I was nearing the completion of my PhD in physics. I knew I wasn’t going to continue in physics and I had no idea what I would do instead. My interest in the personal computers of the day was non-existent. In January 1984 I was out of the country so I missed the introduction of the Mac. But a colleague had a friend who worked for Apple and that friend brought a Mac over to show us. It seemed like magic.

I was totally hooked. Stanford had some Macs that you could go and spend time with, playing with MacPaint and MacWrite. When Apple offered Macs through the university at $1000 (a huge discount from the $2500 list price) I scraped together money I didn’t have and bought one.

In the early days of Macintosh the internet was just a bit different than today. A couple of people at Stanford started the “Info Mac Digest” which was a daily mass mailing that went to thousands of people. It was an incredible information source and consisted entirely of postings from people who shared excitement about this sea change in computing. For a period of time I was moderator of info-mac and through that got to meet many people in the Macintosh community, many of which are colleagues and friends today. I have to take at least partial credit for organizing the “netters dinner” that took place annually around MacWorld. I still remember the year that about 70 of us gathered at MacWorld and walked from Moscone up to Chinatown and overtook the Hunan Restaurant. (See Netter’s Dinner.)

Stanford had a users group, SMUG, that met regularly. Gus Fernandez started a developers group associated with SMUG and he seemed to have every Apple superstar come and talk about Macintosh. I don’t remember everybody but I do remember Andy Hertzfeld, Larry Kenyon, Bruce Horn, Chris Crawford, and Bill Budge coming and blowing everybody away with stories, demos, and more. I still remember Andy saying that even though the LaserWriter had a 12 MHz processor (instead of the 8 MHz of the Mac), running PostScript brought the processor to its knees!

All this motivated me to go to the Stanford library where they had a loose leaf copy of a draft of Inside Macintosh and I started reading. Everything was totally new and exciting but completely foreign to me. I’d only done programming in Fortran previously and Pascal was literally a foreign language. It was nothing like the computing I’d done on mainframes! On July 13, 1985 I went to the “MacAfrica” one day class taught by Dave Wilson (see MacAfrica) and learned a ton.

When I finished grad school and started looking for jobs I had a couple of opportunities with high tech companies doing computing work that didn’t really excite me but they were good opportunities nonetheless. Then by chance I met Dave Gustavson at SLAC who was looking for a Mac programmer to do Mac programming using FORTH on a project to control a piece of hardware. I ended up working for him in the Computation Research Group at SLAC programming the Mac using the fantastic Mach1 programming environment created by Rick Miley and others at the Palo Alto Shipping Company.

One bonus of that job was that Dave got one of the first Apple LaserWriter printers. I got a serial cable and started to learn the PostScript programming language. Since it was syntactically similar to FORTH it was a breeze to get started. This was my real first experience with computer graphics and it was a really easy way to learn. This was helpful when a friend at SLAC, Kathy Dager, put me in touch with Dick Sweet at Adobe Systems.

At Adobe I got the opportunity to do a wide range of things, including teaching PostScript programming classes to a wide range of people, working with a number of high profile software developers, including Apple, Aldus, and Quark. While Adobe was in development of a second version of the PostScript programming language (PostScript Level 2) I got to be part of the design of the language.

When Adobe decided that they needed to write a new LaserWriter driver for the Macintosh, I met Rich Blanchard and he and I co-designed and (with a team of talented people) wrote a new PostScript printer driver for Macintosh. That project became a joint project with Apple and became Apple’s LaserWriter 8 printer driver.

This led to my direct involvement with Apple Computer. Over time I worked with Rich and others from the LaserWriter 8 team at RBI Software Systems where we did contract work for Apple, Adobe, Sun, IBM, and others. After 5 years of working with Apple as a contractor, Apple decided they wanted us to work exclusively for them and our team at RBI became Apple employees. I worked at Apple almost 13 years before leaving in January 2013 to take a break from working in the world of technology.

Without my involvement with Macintosh, I would not have met my wife of 25+ years nor most of the people who are my friends today. It has influenced my career, my personal life, and many of my interests that continue to this day.

So I mean it when I say the introduction of the Macintosh changed my life.

Recently I made an appearance on the Debug podcast, hosted by Guy English and Rene Ritchie. It was terrific fun talking with them and we’ve gotten a lot of positive feedback from listeners. We had so much to talk about that they broke it up into two parts.

In Part 1 we talk about how I got into computing, working with FORTH at Stanford Linear Accelerator Center, my days at Adobe Systems in the late 1980s, working at General Magic, and then RBI Software Systems. Part 1 ends just as we are talking about RBI moving to Apple to work in the Graphics and Imaging Group in June, 2000.

Part 2 begins as I arrive at Apple and begin working on Printing and Graphics just as Mac OS X was ramping up for a beta release in the fall of 2000 and the 10.0 release in the Spring of 2001. It was a fantastic time to start at Apple and be a part of its evolution. And yes, we also talk about bagels.