Skip to content

Instantly share code, notes, and snippets.

@marcelofabri
Last active August 29, 2015 14:22
Show Gist options
  • Save marcelofabri/9c3c710555a41ac192ff to your computer and use it in GitHub Desktop.
Save marcelofabri/9c3c710555a41ac192ff to your computer and use it in GitHub Desktop.
import Foundation
import Quartz
extension Array {
func each(doThis: (element: T) -> Void) {
for e in self {
doThis(element: e)
}
}
}
let documents = DecksetApp()?.documents.first?.slides.map { PDFDocument(data: $0.pdfData) }
let output = PDFDocument()
var pageIndex = 0
documents?.each { doc in
for var i = 0; i < doc.pageCount(); i++ {
let page = doc.pageAtIndex(i)
output.insertPage(page, atIndex: pageIndex)
pageIndex++
}
}
output.writeToFile("/Users/marcelofabri/test.pdf")
println("Exported \(pageIndex) pages")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment