I, too, liked this idea, but was not as expeditious as Adam in completing my implementation. I include it here only as an additional reference. Mine uses the python bindings for Apple's proprietary CoreGraphics extension, and has been quickly tested on 10.5.

#!/usr/bin/python
#
# Shuffles pages of PDF file, writing to <in_filename>-shuffle.pdf
#
# Usage: pdfshuffle.py <in_filename>
#
# Using python bindings for Apple's proprietary CoreGraphics extension:
# http://developer.apple.com/graphicsimaging/pythonandquartz.html

from CoreGraphics import *
import os, sys, random

# input pdf
in_filename = sys.argv[1]
in_filepdf = CGPDFDocumentCreateWithProvider(CGDataProviderCreateWithFilename(in_filename));
assert in_filepdf, "Failed to open input pdf" + in_filename
rect = in_filepdf.getPage(1).getBoxRect(kCGPDFMediaBox)

# permutation
shuffle_page_order = range(1, in_filepdf.getNumberOfPages() + 1)
random.shuffle(shuffle_page_order)

# output pdf
out_filename = in_filename[:in_filename.rfind(".")] + "-shuffle.pdf"
out_filepdf = CGPDFContextCreateWithFilename(out_filename, rect)
assert out_filepdf, "Failed to open output pdf" + out_filename

# write shuffled pages
for page in shuffle_page_order:
    out_filepdf.beginPage(rect)
    out_filepdf.drawPDFDocument(rect, in_filepdf, page)
    out_filepdf.endPage()
out_filepdf.finish()





Regards,
- Stuart Andrews

On Oct 13, 2009, at 12:09 AM, Adam R. Maxwell wrote:


On Oct 12, 2009, at 7:59 PM, James Howison wrote:

You could just create a new temp PDF with the pages jumbled, then ask Skim to open that.

I liked that idea, so I stole it :). In the attached script, I took a slightly different approach, and used PyObjC instead of pdftk to rearrange the PDF. This requires 10.5 or later, but I've only tested it on 10.6. Call from Terminal as rearrange_pdf.py /path/to/ some.pdf and it will create a new PDF with the pages shuffled and open it in Skim.


<rearrange_pdf.py>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Skim-app-users mailing list
Skim-app-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-users

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Skim-app-users mailing list
Skim-app-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-users

Reply via email to