Old Convert2Pdf script

I am trying to convert HTML to PDF. The older versions of PdfCreator came with a COM script example "Convert2Pdf.vbs". Is it possible to make this script work with the latest version "3.4.1"? Or is there a similar script I can run to convert a HTML file to PDF via the command line? Thanks

Hi,

it will be easier to take one of the current examples e.g. TestPage2PDF.vbs and modify it to meet your requirements. You will basically need to replace the "print a testpage" part with "print the html file specified by my input".

Best regards

Robin

Ok. I do not have very much experience with vbs. Can I use the same command "RUNDLL32.exe" to print a local HTML file? Or is there another command I should use? Thanks

Hi,

I shared my printer so now it is available at \Arthur-P52s\PdfCreator.
Then I used the WScript "print" command to replace the command that prints a Windows test page - see code below.

Set ShellObj = WScript.CreateObject("WScript.Shell")
ShellObj.Run "print /d:\Arthur-P52s\PDFCreator C:\Users\arthur\Desktop\test.txt"

When I run the script I get this error on line 45. "printJob.ConvertTo(fullPath)"
Capture

If I run "print /d:\Arthur-P52s\PDFCreator C:\Users\arthur\Desktop\test.txt" from command promt it opens a save dialog. When I click save it gives me a ghostscript error. Any help is appreciated.

Capture2

Hi,

ShellObj.Run "print /d:\Arthur-P52s\PDFCreator C:\Users\arthur\Desktop\test.txt" seems to be working as expected, as it seems to print the file to the PDFCreator printer, triggering the PrintJobWindow.
To find out why you are getting the Ghostscript error after pressing save, please check the log inside %localappdata%\PDFCreator (you can increase the logging detail by setting the log level to "debug" or "trace" in the PDFCreator application settings. Do you not get the error if you manually print the same document to PDFCreator?
If the script is only used for converting, you don't really need the COM interface, you can also call PDFCreator from a command line.

Best regards

Robin

Thanks for the reply. If I right click the file and print it to PDFCreator it prints just fine. here is the log file after running "print /d:\Arthur-P52s\PDFCreator C:\Users\arthur\Desktop\test.txt" in cmd one time.

2019-04-09 12:24:41.1278 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.Shutdown: All synchronized threads have ended
2019-04-09 12:24:41.1278 [Debug] pdfforge.PDFCreator.Core.Communication.PipeServerManager.PrepareShutdown: Preparing PipeServer for ShutDown
2019-04-09 12:24:41.1278 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.Shutdown: Shutting down the application
2019-04-09 12:24:41.1278 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.Shutdown: Exiting...
2019-04-09 12:24:41.1278 [Debug] pdfforge.PDFCreator.UI.Presentation.Helper.SettingsLoaderBase.SaveSettingsInRegistry: Saving settings
2019-04-09 12:24:41.4536 [Debug] pdfforge.PDFCreator.Core.Communication.PipeServerManager.Shutdown: Stopping pipe server
2019-04-09 12:24:41.4665 [Debug] pdfforge.PDFCreator.Editions.EditionBase.ProgramBase.Main: Ending PDFCreator
2019-04-09 12:24:44.0604 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.SendMessageOrStartApplication: Starting attempt 1:
2019-04-09 12:24:44.0724 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.TryStartApplication: Starting pipe server
2019-04-09 12:24:44.0724 [Debug] pdfforge.PDFCreator.Core.Communication.PipeServerManager.StartServer: Starting pipe server thread
2019-04-09 12:24:44.0724 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.TryStartApplication: Reloading settings
2019-04-09 12:24:44.1785 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.TryStartApplication: Finding spooled jobs
2019-04-09 12:24:44.1785 [Debug] pdfforge.PDFCreator.Conversion.Jobs.SpooledJobFinder.GetJobs: Looking for spooled jobs in 'C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool'
2019-04-09 12:24:44.1785 [Debug] pdfforge.PDFCreator.Conversion.Jobs.SpooledJobFinder.GetJobs: Found inf file: C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: New JobInfo: C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: DocumentTitle: Local Downlevel Document
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: ClientComputer: \[::1]
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: SessionId: 1
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: PrinterName: PDFCreator
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: JobCounter: 12
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: JobId: 14
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: Added JobInfo: C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.StartSynchronizedThread: Adding thread ProcessingThread
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.NewPrintJobStart.StartApplication: Adding new job
2019-04-09 12:24:44.2239 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueueManager.ProcessJobs: New PrintJob C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf from Printer PDFCreator
2019-04-09 12:24:44.2368 [Debug] pdfforge.PDFCreator.Core.Workflow.JobBuilder.BuildJobFromJobInfo: Profile: (GUID DefaultGuid)
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: New JobInfo: C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: DocumentTitle: Local Downlevel Document
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: ClientComputer: \[::1]
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: SessionId: 1
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: PrinterName: PDFCreator
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: JobCounter: 12
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Workflow.JobInfoQueue.Add: JobId: 14
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.SendMessageOrStartApplication: TryStartApplication: True
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.SendMessageOrStartApplication: Starting update check thread
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.StartSynchronizedThread: Adding thread UpdateThread
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.SendMessageOrStartApplication: Starting Cleanup thread
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.UI.Presentation.Assistants.Update.UpdateAssistant.UpdateThread: Launched UpdateThread
2019-04-09 12:24:44.2623 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.StartSynchronizedThread: Starting CleanUpThread thread
2019-04-09 12:24:44.2684 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.StartSynchronizedThread: Adding thread CleanUpThread
2019-04-09 12:24:44.2684 [Debug] pdfforge.PDFCreator.Core.Startup.AppStarts.MaybePipedApplicationStarter.Shutdown: Waiting for all threads to finish
2019-04-09 12:24:44.2684 [Debug] pdfforge.PDFCreator.UI.Presentation.Assistants.Update.UpdateAssistant.ShowUpdate: Update period did not pass. Next Update is set to: 4/16/2019 9:46:59 AM
2019-04-09 12:24:44.2684 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.WaitForThreads: Waiting for all synchronized threads to end
2019-04-09 12:24:44.2684 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.WaitForThreads: 2 Threads remaining
2019-04-09 12:24:44.2912 [Debug] pdfforge.PDFCreator.Core.Workflow.ConversionWorkflow.PrepareAndRun: Starting conversion...
2019-04-09 12:24:44.2912 [Debug] pdfforge.PDFCreator.Core.Workflow.JobDataUpdater.GetNumberOfCopies: Number of copies from source files: 1
2019-04-09 12:24:44.2912 [Warn] pdfforge.PDFCreator.Core.Workflow.PageNumberCalculator.NumberOfPagesFromSourceFiles: Problem detecting number of pages from source file(s). Set to 1.
2019-04-09 12:24:44.2912 [Debug] pdfforge.PDFCreator.Core.Workflow.PageNumberCalculator.NumberOfPagesFromSourceFiles: Number of pages from source files: 1
2019-04-09 12:24:44.3072 [Debug] pdfforge.PDFCreator.UI.Presentation.Workflow.InteractiveWorkflow.DoWorkflowWork: Starting PrintJobWindow
2019-04-09 12:24:46.0062 [Debug] pdfforge.PDFCreator.Core.Workflow.JobRunner+d__10.MoveNext: Output filename template is: C:\Users\arthur\Desktop\Local Downlevel Document.pdf
2019-04-09 12:24:46.0062 [Debug] pdfforge.PDFCreator.Core.Workflow.JobRunner+d__10.MoveNext: Output format is: Pdf
2019-04-09 12:24:46.0062 [Info] pdfforge.PDFCreator.Core.Workflow.JobRunner+d__10.MoveNext: Converting C:\Users\arthur\Desktop\Local Downlevel Document.pdf
2019-04-09 12:24:46.0212 [Debug] pdfforge.PDFCreator.Conversion.Ghostscript.Conversion.GhostscriptConverter.GetGhostscript: Ghostscript Version: loaded from C:\Program Files\PDFCreator\Ghostscript\Bin\gswin32c.exe
2019-04-09 12:24:46.0212 [Debug] pdfforge.PDFCreator.Conversion.Ghostscript.Conversion.GhostscriptConverter.DoConversion: Starting Ghostscript Job
2019-04-09 12:24:46.0381 [Debug] pdfforge.PDFCreator.Conversion.Ghostscript.OutputDevices.OutputDevice.GetGhostScriptParameters: Created metadata file "C:\Users\arthur\AppData\Local\Temp\PDFCRE~1\Temp\JOB_ZE~1\metadata.mtd"
2019-04-09 12:24:46.0491 [Debug] pdfforge.PDFCreator.Conversion.Ghostscript.GhostScript.Run: Ghostscript Parameters:
gs
-IC:\Program Files\PDFCreator\Ghostscript\Bin;C:\Program Files\PDFCreator\Ghostscript\Lib;C:\Program Files\PDFCreator\Ghostscript\Fonts
-sFONTPATH=C:\WINDOWS\Fonts
-dNOPAUSE
-dBATCH
-sOutputFile=C:\Users\arthur\AppData\Local\Temp\PDFCRE~1\Temp\JOB_ZE~1\TEMPOU~1\output.pdf
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.4
-dPDFSETTINGS=/default
-dEmbedAllFonts=true
-dAutoRotatePages=/PageByPage
-dParseDSCComments=false
-sColorConversionStrategy=RGB
-dProcessColorModel=/DeviceRGB
-dConvertCMYKImagesToRGB=true
-dAutoFilterColorImages=true
-dAutoFilterGrayImages=true
-dEncodeColorImages=true
-dEncodeGrayImages=true
-dColorImageFilter=/DCTEncode
-dGrayImageFilter=/DCTEncode
-dEncodeMonoImages=true
-dMonoImageFilter=/CCITTFaxEncode
-f
C:\Users\arthur\AppData\Local\Temp\PDFCRE~1\Spool\14-5A9~1.PS
C:\Users\arthur\AppData\Local\Temp\PDFCRE~1\Temp\JOB_ZE~1\metadata.mtd
2019-04-09 12:24:46.2640 [Error] pdfforge.PDFCreator.Conversion.Ghostscript.Conversion.GhostscriptConverter.DoConversion: Ghostscript execution failed: Error: /undefined in test1
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1007/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Current file position is 6

2019-04-09 12:24:46.2640 [Error] pdfforge.PDFCreator.Conversion.Ghostscript.Conversion.GhostscriptConverter.DoConversion: There was a Ghostscript error while converting the Job C:\Users\arthur\AppData\Local\Temp\PDFCreator\Spool\14-5A94350767B84666B1833901AE925660.inf: pdfforge.PDFCreator.Conversion.Jobs.ProcessingException: Ghostscript execution failed: Error: /undefined in test1
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1007/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Current file position is 6

at pdfforge.PDFCreator.Conversion.Ghostscript.Conversion.GhostscriptConverter.DoConversion(Job job)
2019-04-09 12:24:46.2640 [Error] pdfforge.PDFCreator.Core.Workflow.JobRunner+d__10.MoveNext: The job failed: Ghostscript execution failed: Error: /undefined in test1
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1007/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Current file position is 6

(Conversion_GhostscriptError)
2019-04-09 12:24:46.2987 [Error] pdfforge.PDFCreator.Core.Workflow.ConversionWorkflow.RunWorkflow: Error Conversion_GhostscriptError: Ghostscript execution failed: Error: /undefined in test1
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1007/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Current file position is 6

2019-04-09 12:24:48.0516 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.StartSynchronizedThread: Adding thread
2019-04-09 12:24:48.0516 [Error] pdfforge.PDFCreator.Core.Workflow.JobInfoQueueManager.ProcessJob: The job 'Local Downlevel Document' terminated at step Error and did not end successfully.
2019-04-09 12:24:48.0516 [Debug] pdfforge.PDFCreator.Utilities.Threading.ThreadManager.WaitForThreads: 1 Threads remaining

Thanks

Hi,

it seems the command directly sends the text to the printer or is trying to interpret the .txt file as Postscript. I originally assumed it would check for the "print" command associated to the file type in the registry and execute that. But you can actually also still use the COM interface to print the file, which is most likely the easiest solution:
http://docs.pdfforge.org/pdfcreator/3.4/en/pdfcreator/com-interface/reference/pdfcreator/

Best regards

Robin