I wrote the script below, but no matter what I do, I can't seem to get the output in anything except A4 paper size. The brochure command is through the pdfforge.dll, which I don't see source code for anywhere.
The papersize issues within PDF Creator have been a pain the in the butt for as long as I've been using it (5 years at least).
A work around may be to print to A4 (two places to change it in printer preferences in the control panel) and then print again, scaling to Letter size.
` ' This always prints to paper size A4, even if PDFCreator is set up to print to`
`' a different size, and even if printing to the alternate size works for`
`' non-brochure printing.`
`
`
`' Apparently, the PDFCreator user interface needs to be open before printing`
`' Otherwise, the action is not performed during printing and it is missing the`
`' next time the UI is opened.`
`Option Explicit`
`
`
`' added to the end of the filename when outputting the brochure`
`Const suffix = "_brochure"`
`
`
`' filenames and other strings`
`Dim ifname, ofname`
`' settings to remember`
`Dim DefaultPrinter, closed`
`' objects`
`Dim objArgs, fso, PDFCreator`
`' script stuff`
`Dim i, AppTitle, Scriptname, ScriptBasename`
` `
`Set fso = CreateObject("Scripting.FileSystemObject")`
`
`
`Scriptname = fso.GetFileName(Wscript.ScriptFullname)`
`ScriptBasename = fso.GetFileName(Wscript.ScriptFullname)`
`
`
`AppTitle = "PDFCreator - " & ScriptBaseName`
`
`
`If CDbl(Replace(WScript.Version,".",",")) < 5.1 then`
` MsgBox "You need the ""Windows Scripting Host version 5.1"" or greater!", _`
` vbCritical + vbSystemModal, AppTitle`
` Wscript.Quit 1`
`End if`
`
`
`Set objArgs = WScript.Arguments`
`If objArgs.Count = 0 Then`
` MsgBox "Syntax: " & vbtab & Scriptname & " " & vbcrlf & _`
` vbtab & "or use ""Drag and Drop""!", _`
` vbExclamation + vbSystemModal, AppTitle`
` WScript.Quit 1`
`End If`
`
`
`' initialize and save some settings`
`Set PDFCreator = Wscript.CreateObject("PDFCreator.clsPDFCreator", "PDFCreator_")`
`PDFCreator.cStart '"/NoProcessingAtStartup"`
`With PDFCreator`
` DefaultPrinter = .cDefaultprinter`
` closed = .cIsClosed`
` `
` .cDefaultprinter = "PDFCreator"`
` `
` ' some attempts at getting the papersize to work... failed`
` .cOption("UseAutosave") = 1`
` .cOption("UseAutosaveDirectory") = 1`
` .cOption("AutosaveFormat") = 0 ' 0 = PDF`
` .cOption("UseFixPapersize") = 1`
` `
` ' The paper size reported changes according to the setting, `
` ' but the brocure function still ignores the setting`
` MsgBox "PaperSize: " & .cOption("Papersize")`
` .cOption("PaperSize") = "letter"`
` MsgBox "PaperSize: " & .cOption("Papersize")`
`
`
` .cSaveOptions `
` .cClearcache`
` .cPrinterStop = false`
`End With`
`
`
`' create the brochures for each input file given`
`For i = 0 to objArgs.Count - 1`
` ifname = objArgs(i)`
` If Not CheckInputFile(ifname) Then Exit For`
` `
` ofname = fso.GetParentFolderName(ifname) & "\\" & _`
` fso.GetBaseName(ifname) & suffix & ".pdf"`
` If Not CheckOutputFile(ofname) Then Exit For`
` `
`MsgBox "Processing brochure... " & vbCrLf & _`
` " Input: " & vbTab & ifname & vbCrLf & _`
` " Output:" & vbTab & ofname & vbCrLf`
` CreateBrochure ifname, ofname`
`MsgBox "Processing " & ifname & " done."`
`Next`
`
`
`' clean up PDFCreator and set settings back to their original settings`
`With PDFCreator`
` .cDefaultprinter = DefaultPrinter`
` .cClearCache`
` WScript.Sleep 200`
` If closed then .cClose`
`End With`
`WScript.Quit 0`
`
`
`'-------------------------------------------------------------------------------`
`
`
`Function CheckInputFile (filename)`
` `
` If Not fso.FileExists(filename) Then`
` MsgBox "Can't find the file: " & filename, _`
` vbExclamation + vbSystemModal, AppTitle`
` CheckInputFile = False`
` Exit Function`
` End If`
` `
` Dim ext`
` ext = fso.GetExtensionName(filename)`
` If Ucase(ext) <> "PDF" And Ucase(ext) <> "TMP" Then`
` MsgBox "This script works only with pdf files!" & vbCrLf & _`
` "Extension '" & ext & "' was given.", _`
` vbExclamation + vbSystemModal, AppTitle`
` CheckInputFile = False`
` Exit Function`
` End If`
` `
` CheckInputFile = True`
`End Function`
`
`
`Function CheckOutputFile (filename)`
` Dim vbResponse`
` `
` vbResponse = -1`
` If fso.FileExists(filename) Then`
` vbResponse = MsgBox("The file already exists. Do you want to replace it?" & vbcrlf & vbcrlf & _`
` "File: " & filename, _`
` vbOKCancel, AppTitle)`
` End If`
` `
` If vbResponse = vbCancel Then`
` CheckOutputFile = False`
` Exit Function`
` ElseIf vbResponse = vbOK Then`
` fso.DeleteFile(filename)`
` ' see if it actually got deleted`
` If fso.FileExists(filename) Then`
` MsgBox "The file could not be deleted. Skipping." & vbcrlf & vbcrlf & _`
` "File: " & filename`
` vbResponse = vbCancel`
` End If`
` Else`
` ' file doesn't exist, so we don't need to worry about it`
` End If`
` `
` CheckOutputFile = True`
`End Function`
`
`
`Function CreateBrochure(ifname, ofname)`
` Dim pdf`
` Set pdf = WScript.CreateObject("pdfforge.pdf.pdf")`
` pdf.Brochure ifname, ofname`
` Set pdf = Nothing`
` CreateBrochure = True`
`End Function`