Code by Kevin
   


About
Code by Kevin: Programming, code, business, and other pursuits

Your Host
Kevin Walzer, software developer.

Home

Subscribe to RSS Feed
Get a syndicated feed of my weblog.

Archives
2012
2011
2010
2009
2008
2007
2006

Categories
Business
Software
General

        home
Wed, 18 Aug 2010

Mac-native printing, revisited

I'm now at work on integrating my cocoaprint library into my Tk applications. As I've discussed previously, cocoaprint is a departure for me in making use of Mac-native API's for printing: Cocoa for the print dialogs, and CorePrinting for interacting with the printer.

Yet the old Unix command-line tools that I've relied on in the past to help manage print jobs have not gone away completely. In fact, I continue to marvel at the power of these tools--not only the traditional Unix tools, but also Mac-specific tools in which Apple exposes Mac-native API's to a command-line interface. While I'm no longer using the "lpr" tool to send print data to the printer, I am making use of other tools in preparing print jobs:

  • textutil.This is an Apple-specific tool that exposes much of the Cocoa text system to command-line operations. It converts text between several different formats, including HTML, plain text, and rich text format. I use this tool to convert HTML to text for printing.
  • iconv.This is a tool that converts between different kind of text encoding: I use it to convert text from rich Unicode to simple ASCII.
  • enscript.This is a Unix tool that converts plain text to PostScript, a precursor to PDF files.
  • pstopdf.This is an Apple-developed tool that converts PostScript to PDF format; it's part of Apple's Common Unix Printing System (CUPS), which runs on nearly every Unix system.

I absolutely love the Mac's Unix foundations because of tools such as these, and even as I expand my capabilities with the Cocoa frameworks, I continue to lean on the Unix tools and the power they provide.

[/general] permanent link