I use CorelDRAW X6 update 4 on Win 7 64 bit.
I want to use VisualBasic script to export documents to PDF using predefined PDF presets. So I'm going to use the method 'Load' like it is suggested in the CorelDRAW documentation:
The following VBA example loads the PDF for Document Distribution publishing style and uses it to publish the active document to PDF.
ActiveDocument.PDFSettings.Load "PDF for Document Distribution"
ActiveDocument.PublishToPDF "C:\MyDocument.pdf"
My problem is that the method 'Load' does not work. Disregarding which preset I specify the resulting PDF is always saved with one and the same default preset so I always have the identical PDF file. Also the method 'Load' always returns True even if I provide an incorrect preset name. Here is my script code:
Dim theInputFilePath, theSavedPDFPath, thePDFPreset
theInputFilePath = Wscript.Arguments.Item(0)
thePDFPreset = Wscript.Arguments.Item(1)
theSavedPDFPath = theInputFilePath & " (" & thePDFPreset & ").pdf"
Dim objCDR
Set objCDR = CreateObject("CorelDRAW.Application")
Dim objDoc
Set objDoc = objCDR.OpenDocument(theInputFilePath)
If objDoc.PDFSettings.Load(thePDFPreset) Then
objDoc.PublishToPDF(theSavedPDFPath)
Wscript.Echo("Published to PDF: " & theSavedPDFPath)
Else
Wscript.Echo("Cannot publish to PDF: failed to load PDF preset")
End If
objDoc.Close
objCDR.Quit
Set objCDR = Nothing
Here is the description how to reproduce the problem:
- save the script into file like TestScript.vbs
- execute it in command line:
"TestScript.vbs c:\Test.cdr PresetName"
where PresetName is one of the predefined CorelDRAW presets or a custom preset or even not existing preset - in all cases the resulting PDF file is exactly the same and there is never any error displayed. It looks like the resulting PDF is created using the default preset that I used last time when exporting to PDF from CorelDRAW manually.
To avoid any doubts I created the custom preset 'NoFontsPreset' with the setting to convert all fonts to outlines and when I'm using it in CorelDRAW GUI then resulting PDF does not contain any fonts as expected. But when I'm trying to use it in the script:
"TestScript.vbs c:\Test.cdr NoFontsPreset"
then fonts are still there and the file has the same size as in all previous tests.
Is there a problem in my script or method 'Load' does not work as described in the documentation?