Apply Quartz filter to a PDF from command line

Hello

I'm trying to apply a quartz filter to a PDF document via the command line. I know it's possible with Python and there's a script at /Developer/Examples/Quartz/Python/filter-pdf.py that does just that. The problem with this is that the script is Python 2.3 and my OS X 10.5.8 is running Python 2.5 - so I'm getting the error message:

+<Error>: The function `CGPDFDocumentGetMediaBox' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGPDFPageGetBoxRect' instead.+

I don't know Pyton but I checked the file and I grep'ed the Developer folder to see if I can find where CGPDFDocumentGetMediaBox is being used, but no matter what I changed, I didn't manage to get the script working.

So I guess my question is one of the following:
How can I update the developer example to a new, functioning version?
or how do I get rid of the deprecated functions that script is using?
or is there any other way to apply a quartz filter to a PDF via the command line? (I've read that SIPS is able to accomplish this, but I couldn't find out how..)

Thank you for any help!
Cheers

Macbook white, Mac OS X (10.5.8), Python 2.3

Posted on Apr 6, 2010 7:50 AM

Reply
1 reply
Sort By: 

Apr 7, 2010 3:06 AM in response to thephore

There a quartz filter printer hidden in OS X which makes applying a quartz filter to a PDF file on the command line a piece of cake. This is the syntax:
+/System/Library/Printers/Libraries/./quartzfilter inputfile filterpath outputfile+

So if I wanted to convert big.pdf to small.pdf it would go like this:$
+/System/Library/Printers/Libraries/quartzfilter big.pdf /System/Library/Filters/Reduce\ File\ Size.qfilter small.pdf+

The "Reduce File Size" filter isn't that great though when it comes to reducing the file size for printing. Jerome Colas wrote a nice article about quartz filters though: http://discussions.apple.com/thread.jspa?messageID=6109445&tstart=0

You can also create your own with the ColorSync utility in Mac OS X. A Quartz filter is nothing but an XML, so you could also generate one on the fly if necessary.

Resource: http://macscripter.net/viewtopic.php?id=25916
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apply Quartz filter to a PDF from command line

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.