Skip to content

Instantly share code, notes, and snippets.

@jrk jrk/
Last active Jan 27, 2016

What would you like to do?
Executable script to run Quartz filters on a PDF file from the shell

This is a simple, should-be-drop-in replacement for the old /System/Library/Printers/Libraries/quartzfilter utility which went away circa OS X 10.8.


chmod +x quartzfilter.js
./quartzfilter.js infile.pdf filter.qsfilter outfile.pdf


./quartzfilter.js my-big-pdf.pdf "/System/Library/Filters/Reduce File Size.qfilter" my-less-big-pdf.pdf

Built using direct calls into Quartz.framework from JavaScript for Automation (JSX).

#!/usr/bin/env osascript -l JavaScript
function save(inpath, filterpath, outpath) {
inURL = $.NSURL.fileURLWithPath(inpath)
inPDF = $.PDFDocument.alloc.initWithURL(inURL)
filterURL = $.NSURL.fileURLWithPath(filterpath)
filter = $.QuartzFilter.quartzFilterWithURL(filterURL)
inPDF.writeToFileWithOptions(outpath, $({"QuartzFilter": filter}))
function run(argv) {
if (argv.length != 3) {
console.log("Usage: quartzfilter.js inPDF qsfilter outPDF")
save(argv[0], argv[1], argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.