Created
July 16, 2010 04:32
-
-
Save masanobuimai/477924 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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