Introduction:
This article contains code examples to reset some (but not all) of the default settings of PDFCreator.
These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here [1]. Please note that this code will NOT work with Adobe Acrobat.
It should be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding [2].
Routines Included In This Article:
- Reset PDFCreator's Default Settings [2]
- List PDFCreator's Default Values [2]
Versions Tested:
These routines were tested successfully using PDFCreator 0.9.1, GPLGhostscript.exe download package, on Windows XP Pro (SP2). Excel versions tested include:
- Excel 2003
- Excel 2007
NOTE: Before you "go it alone" with trying to adapt any of these routines, you may want to read this article [3], which shares some of the idiosyncrasies discovered in the development of the PDFCreator code samples.
www.excelguru.ca [4]) 'Macro Purpose: Reset the PDFCreator seetings to their default values Dim objPDF As New PDFCreator.clsPDFCreator With objPDF If .cStart("/NoProcessingAtStartup") = False Then MsgBox "Can't initialize PDFCreator.", vbCritical + _ vbOKOnly, "PrtPDFCreator" Exit Sub End If 'Set Values .cOption("UseAutosave") = 0 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveDirectory") = "\" .cOption("AutosaveFilename") = "" .cOption("AutosaveFormat") = 0 .cOption("UseCreationdate") = vbNullString .cOption("UseStandardAuthor") = 0 .cOption("PDFUseSecurity") = 0 .cOption("PDFUserPass") = 0 .cOption("PDFUserPassString") = vbNullString .cOption("PDFOwnerPass") = 1 .cOption("PDFOwnerPassString") = vbNullString .cOption("PDFEncryptor") = 0 .cOption("PDFDisallowCopy") = 1 .cOption("PDFDisallowPrinting") = 0 .cOption("PDFDisallowModifyContents") = 0 .cOption("PDFDisallowModifyAnnotations") = 0 .cOption("PrinterTempPath") = "PDFCreator\" 'Save Values .cSaveOptions End With Set objPDF = Nothing End Sub
www.excelguru.ca [5]) 'Macro Purpose: List PDFCreator defaults in Immediate window Dim objPDF As New PDFCreator.clsPDFCreator With objPDF If .cStart("/NoProcessingAtStartup") = False Then MsgBox "Can't initialize PDFCreator.", vbCritical + _ vbOKOnly, "PrtPDFCreator" Exit Sub End If 'Determine Values Debug.Print ".cOption(""UseAutosave"") = " & .cOption("UseAutosave") Debug.Print ".cOption(""UseAutosaveDirectory"") = " & .cOption("UseAutosaveDirectory") Debug.Print ".cOption(""AutosaveDirectory"") = " & .cOption("AutosaveDirectory") Debug.Print ".cOption(""AutosaveFilename"") = " & .cOption("AutosaveFilename") Debug.Print ".cOption(""AutosaveFormat"") = " & .cOption("AutosaveFormat") Debug.Print ".cOption(""UseCreationdate"") = " & .cOption("UseCreationdate") Debug.Print ".cOption(""UseStandardAuthor"") = " & .cOption("UseStandardAuthor") Debug.Print ".cOption(""PDFUseSecurity"") = " & .cOption("PDFUseSecurity") Debug.Print ".cOption(""PDFUserPass"") = " & .cOption("PDFUserPass") Debug.Print ".cOption(""PDFUserPassString"") = " & .cOption("PDFUserPassString") Debug.Print ".cOption(""PDFOwnerPass"") = " & .cOption("PDFOwnerPass") Debug.Print ".cOption(""PDFOwnerPassString"") = " & .cOption("PDFOwnerPassString") Debug.Print ".cOption(""PDFEncryptor"") = " & .cOption("PDFEncryptor") Debug.Print ".cOption(""PDFDisallowCopy"") = " & .cOption("PDFDisallowCopy") Debug.Print ".cOption(""PDFDisallowPrinting"") = " & .cOption("PDFDisallowPrinting") Debug.Print ".cOption(""PDFDisallowModifyContents"") = " & .cOption("PDFDisallowModifyContents") Debug.Print ".cOption(""PDFDisallowModifyAnnotations"") = " & .cOption("PDFDisallowModifyAnnotations") Debug.Print ".cOption(""PrinterTempPath"") = " & .cOption("PrinterTempPath") End With Set objPDF = Nothing End Sub
Thanks
Just a quick little note of thanks to the person who emailed me to point out that I had failed to see the .cSaveOptions method in the object browser!