Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Convert RTF ot PDF using pdfcreator

$
0
0
Trying to modify sample vbs script from pdf creator to convert an rtf file to a pdf.

I am having an issue with the shell execute.

Can someone please give me the right syntax.

' PDFCreator COM Interface test for VBScript
' Part of the PDFCreator application
' License: GPL
' Homepage: http://www.pdfforge.org/pdfcreator
' Version: 1.0.0.0
' Created: June, 16. 2015
' Modified: June, 16. 2015
' Author: Sazan Hoti
' Comments: This project demonstrates the use of the COM Interface of PDFCreator.
' This script has been modified to convert rtf to pdf.
' Note: More usage examples then in the VBScript directory can be found in the JavaScript directory only.

Dim ShellObj, PDFCreatorQueue, scriptName, fullPath, printJob, objFSO, tmp

if (WScript.Version < 5.6) then
MsgBox "You need the Windows Scripting Host version 5.6 or greater!"
WScript.Quit
end if

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ShellObj = CreateObject("Shell.Application")
Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue")
fullPath = objFSO.GetParentFolderName(WScript.ScriptFullname ) & "\\report.pdf "

MsgBox "Initializing PDFCreator queue..."
PDFCreatorQueue.Initialize

MsgBox "Set default printer to pdf creator and print .rtf"


ShellObj.ShellExecute "print","c:\report.rtf","", "open",1


MsgBox "Waiting for the job to arrive at the queue for 10 seconds..."
if not PDFCreatorQueue.WaitForJob(10) then
MsgBox "The print job did not reach the queue within " & " 10 seconds"
else
MsgBox "Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue"

! MsgBox "Merging all available jobs now"
! PDFCreatorQueue.MergeAllJobs

! MsgBox "Now there are " & PDFCreatorQueue.Count & " job(s) in the queue"
! MsgBox "Getting job instance"
Set printJob = PDFCreatorQueue.NextJob

printJob.SetProfileByGuid("DefaultGuid")


MsgBox "Converting under ""DefaultGuid"" conversion profile but with .Tif as output format"
printJob.ConvertTo(fullPath)

if (not printJob.IsFinished or not printJob.IsSuccessful) then
MsgBox "Could not convert the file: " & fullPath
else
MsgBox "Job finished successfully"
end if
end if

MsgBox "Releasing the object"
PDFCreatorQueue.ReleaseCom

Viewing all articles
Browse latest Browse all 688

Trending Articles