[Pythonmac-SIG] CoreGraphics and Python and Panther

Gus Mueller gus at mu.org
Fri Oct 24 23:50:47 EDT 2003


I just wanted to say that wow, the CoreGraphics module in 10.3's python
is awesome.  Very neat, and I'm sure we're going to see some really cool
stuff come out of it.

Making pdf's has never been so easy.

#!/usr/bin/python
import os
from CoreGraphics import *
from urllib2 import *

html = urlopen("http://www.python.org/").read()

pageRect = CGRectMake(0, 0, 612, 792)
ctx = CGPDFContextCreateWithFilename("python.pdf", pageRect)
ctx.beginPage(pageRect)
ctx.drawHTMLTextInRect(CGDataProviderCreateWithString(html), pageRect)
ctx.endPage()
ctx.finish()

os.popen("/usr/bin/open -a Preview python.pdf")


If whomever is responsible for this at Apple is listening- thanks!

-gus

--   
August Mueller
http://flyingmeat.com/
VoodooPad - 1st Place U.S., O'Reilly Mac OS X Innovators Contest round 2
"Christmas means carnage!"  -- Ferdinand, the duck



More information about the Pythonmac-SIG mailing list