Skip to content

Instantly share code, notes, and snippets.

@masanobuimai
Created July 16, 2010 04:32
Show Gist options
  • Save masanobuimai/477924 to your computer and use it in GitHub Desktop.
Save masanobuimai/477924 to your computer and use it in GitHub Desktop.
import org.codehaus.groovy.scriptom.*
Scriptom.inApartment {
def dir = new File("c:/temp")
def pdfApp = new ActiveXObject('Bullzip.PDFPrinterSettings')
def wsh = new ActiveXObject('WScript.Shell')
def wshnw = wsh.createObject("WScript.Network")
wshnw.setDefaultPrinter(pdfApp.getPrinterName())
def adobeReader = wsh.RegRead('HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\AcroRd32.exe\\')
def mergeList = dir.listFiles().findAll { it.canonicalPath ==~ /.*\.pdf$/ }
if (!mergeList) return
def first = mergeList[0]
mergeList.remove(first)
pdfApp.with {
setValue("output", "${dir.canonicalPath}/all.pdf")
setValue("confirmoverwrite", "no")
setValue("showpdf", "no")
if (mergeList)
setValue("mergefile", mergeList.join("|"))
setValue("mergeposition", "top")
setValue("showsettings", "never")
writeSettings(true)
}
"${adobeReader} /n /p /h \"${first}\"".execute()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment