Com Interface Command to force B&W output?

Hi Guys.
New to this forum.
Been using a script created by Frank Heindorfer for some time now to convert an Excel spreadsheet into a .pdf using PDFCreator. It works very well, but now the company want the .PDF output to be Black & White (The Input Spreadsheets are always brightly coloured). Is there a line of code I can add to the script {perhaps similar to “.cOption(“Black&WhiteOutput”) = True”} etc. to achieve this?
Any assistance gratefully received!
Cheers
Tez

Hi,

if all PDFs created need to be b/w, you can enable this in
the printer settings of the PDFCreator virtual printer (windows contol
panel->printers). Otherwise you can create 2 PDFCreator printers, one for b/w and one for colour.

regards,

Robin

Hmmm.  yes, I would have thought that (and have tried same) - but when running the script, the output is most definitely still in colour. - Retested the process this AM - i.e.  set printer preferences in Win7 via Devices and Printers / PDFCreator / Printer Properties / Printing Preferences / Paper/Quality <set radio button for Black & White > / Ok / Ok   prior to envoking the script.
Run the script on a test sample, and the resulting PDF is still in colour.   Check back through the settings, and the preferences still show set for Black & White output.   :-S      Quite strange.   It was this very behaviour that prompted me to search out this forum and ask for assistance…

Hi,

have you tested, if the b/w setting works when printing manually (without the script)?
Did you setup 2 printers, or did you set the default PDFCreator printer to b/w?
Is the script one of those provided together with the PDFCreator (if yes, which?) or customized?
At the moment i can´t tell what is wrong, will need to reproduce this first.

regards,

Robin

Hi Robin.
B&W printing manually instigated using PDFCreator from within Excel works fine.
I set the Default Printer to B&W.
Script as below:

    ’ Convert2PDF.vbs script
    ’ Part of PDFCreator
    ’ License: GPL
    ’ Homepage: http://www.pdfforge.org/products/pdfcreator
    ’ Windows Scripting Host version: 5.1
    ’ Version: 1.1.0.0
    ’ Date: December, 24. 2007
    ’ Author: Frank Heindörfer
    ’ Comments: This script convert a printable file in a pdf-file using
    ’ the com interface of PDFCreator.

    Option Explicit

    Const maxTime = 120 ’ in seconds
    Const sleepTime = 250 ’ in milliseconds

    Dim objArgs, ifname, fso, PDFCreator, DefaultPrinter, ReadyState,
    i, c, 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
    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
    End If

    Set PDFCreator = Wscript.CreateObject(“PDFCreator.clsPDFCreator”, "PDFCreator
")
    PDFCreator.cStart “/NoProcessingAtStartup”
    With PDFCreator
    .cOption(“UseAutosave”) = 1
    .cOption(“UseAutosaveDirectory”) = 1
    .cOption(“AutosaveFormat”) = 0
    ’ 0 = PDF
    DefaultPrinter = .cDefaultprinter
    .cDefaultprinter = “PDFCreator”
    .cClearcache
    .cPrinterStop = false
    End With

    For i = 0 to objArgs.Count - 1
    With PDFCreator
    ifname = objArgs(i)
    If Not fso.FileExists(ifname) Then
    MsgBox "Cant find the file: " & ifname, vbExclamation + vbSystemModal, AppTitle
    Exit For
    End If
    if Not .cIsPrintable(CStr(ifname)) Then

    Dim objFSO
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    objFSO.CopyFile ifname, “C:\PrintFiles\Error”, True
    objFSO.DeleteFile(ifname)

    Exit For
    End if

    ReadyState = 0
    'Below is the directory where your converted documents will be ouput to.
    .cOption(“AutosaveDirectory”) = “C:\PrintFiles\Completed”
    .cOption(“AutosaveFilename”) = fso.GetBaseName(ifname)
    .cPrintfile cStr(ifname)

    c = 0
    Do While (ReadyState = 0) and (c < (maxTime * 100 / sleepTime))
    c = c + 1
    Wscript.Sleep sleepTime
    Loop
    If ReadyState = 0 then

    objFSO.CopyFile ifname, “C:\PrintFiles\Error”, True
    objFSO.DeleteFile(ifname)

    Exit For
    End If
    End With
    Next

    With PDFCreator
    .cDefaultprinter = DefaultPrinter
    .cClearcache
    WScript.Sleep 20
    .cClose
    End With

    ' PDFCreator events

    Public Sub PDFCreator_eReady()
    ReadyState = 1
    End Sub

    Public Sub PDFCreator_eError()
    MsgBox “An error is occured!” & vbcrlf & vbcrlf & _
    “Error [” & PDFCreator.cErrorDetail(“Number”) & "]: " & PDFcreator.cErrorDetail(“Description”), vbCritical + vbSystemModal, AppTitle
    Wscript.Quit
    End Sub

~~~~~~~~
I have made no changes to the script - I have set up the appropriate folders on the client workstation to match the script.    As mentioned previously, the script runs as would be expected - It processes a file found in the C:\PrintFiles\In folder, creating a PDF and placing it in the C:\PrintFiles\Completed folder, then moving the processed document to the C:\PrintFiles\Original folder. It’s just that as it runs, (despite the settings!) it simply does not convert the coloured document to B&W as should happen.

I guess to fully elaborate, I should mention that for automatic processing of multiple PDFs creation, there is another script that repeats the processing script above for each file found in the “In” folder :

    '#################################################################
    'This script relies on the Convert2PDF script that ships with PDFCreator (with some modifications). This script expects it
    'to be placed on the root of drive C. Convert2PDF must be edited to output the finished PDF files
    'to a directory of your choosing.
    '#################################################################
    On Error Resume next
    Dim Fso
    Dim Files
    Dim objFSO
    Dim wshShell
    Set wshShell=wscript.createobject(“wscript.shell”)
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Dim objFolder

    '#################################################################
    'Directory where files should be placed to be converted to PDF format
    '#################################################################
    Set objFolder = objFSO.GetFolder(“C:\PrintFiles\In”)

    Dim objWMIService, objProcess, colProcess
    Dim strComputer, strProcessKill
    strComputer = “.”

    '#################################################################
    'Convert each file in the “In” directory to PDF format using PDFCreator, then move the file to
    'the “Original” folder.
    '#################################################################

    For Each File in objFolder.Files

    '#################################################################
    'Name of PDFCreator process to be killed if already running
    '#################################################################
    strProcessKill = “‘PDFCreator.exe’”

    '#################################################################
    'Check if above process is running and kill it if it is
    '#################################################################

    Set objWMIService = GetObject(“winmgmts:”     & “{impersonationLevel=impersonate}!\”     & strComputer & “\root\cimv23”)

    Set colProcess = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = " & strProcessKill )
    For Each objProcess in colProcess
    objProcess.Terminate()
    Next

    strCommand="wscript " & "C:\Convert2PDF.vbs " & “C:\PrintFiles\In” & Chr(34) & File.Name & Chr(34)
    Set objExec=wshShell.Exec(strCommand)
    Do Until objexec.status <> 0
    wscript.sleep 25
    loop

    objFSO.CopyFile “C:\PrintFiles\In” & File.Name, “C:\PrintFiles\Original”, True
    objFSO.DeleteFile(“C:\PrintFiles\In” & File.Name)

    next

    wscript.quit

~

But I don’t see how the “automation” script could influence the behaviour of PDFCreator with regard to B&W or Coloured output…

I found both of these scripts on the 'net originally (@ pdfforge - I believe) and as a system, it works, just doesn’t give B&W when it aught to according to the settings!

Thanks for your help Robin… I hope this is of more use to you!

Hi,

i just tested it, using this script, but can´t reproduce the problem here, it is working switching between b/w and colour. Do you have the latest PDFCreator version installed? Which type of file are you converting? I tried with an excel spreadsheet,

regards,

Robin