[Pythonmac-SIG] PDF creation using CoreGraphics

João Leão joaoleao at gmx.net
Wed Jul 21 18:24:43 CEST 2004


Hi list!

I've been doing some experiences with CoreGraphics to generate PDF 
documents. As a starting point I took a look at the examples in 
"/Developer/Examples/Quartz/Python/".

Examining the "image.py" example I was able to write a script that 
imports an image, resizes and places it in a PDF Page. For this I'm 
using the same steps as in that example. The placement of the image is 
made with the method "drawImage" in the PDF Context, that draws the 
image in a given rect.

However, I noticed that the PDF gets the same size (in this case 3,7 M 
because it was a big image) even if I "resize" it to an area of 50 x 50 
px.
It appears that "drawImage" scales the image but maintains the number 
of pixels. This is very clear when you zoom the PDF.
Maybe I have to -really- resize the image before I place it in the PDF 
or maybe there is some way of optimizing the PDF after.
I need it to be lightweight. Any suggestions on how to do this?

Before asking here I looked the documentation (the API and the Apple 
Docs) which I think is good, but couldn't figure it out. I'm not an 
experienced programmer and don't know how to 'glue' all this classes 
and methods to address my needs...

Thanks everyone.

_
joao



More information about the Pythonmac-SIG mailing list