Convert Html To PDF via VBSCRIPT : how not to show printer windows before converting

Hello,

I have created a script to convert an html file to a pdf in a silent mode.
But the printer dialog always show. Then i have to select and click print to process to the conversion.

How i can avoid this ?

PdfCreator is my default printer.

Thanks by advance.

Hi,

this is not done by PDFCreator, but by the application printing the html to the PDFCreator printer.
What code do you use for printing? Do you directly call a browser executable in combination with a print parameter? The PDFCreator print command will only look up the command registered for printing the selected filetype and execute what it finds, it can't tell if the command will be silent or not.

Best regards

Robin

Hello Robin,

To print i use the function PrintFile from the code:

Function Generer_PDF(numOF)

' Auteur: Alexandre Iroulapane
' Date : 20/09/2019
' Description : Génère un PDF à partir d'un fichier html

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

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ShellObj = CreateObject("Shell.Application")
Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue")
Set PDFCreator = CreateObject("PDFcreator.PDFCreatorObj")
fullPath = "C:" & trim(NumOF)&".html"

'On Lance l'impression du fichier html

PDFCreator.PrintFile "C:" & trim(NumOF) & ".html"

'Initialisation de la file d'attente PDF Creator
On Error resume next
PDFCreatorQueue.Initialize

'On récupère le travail dans la file d'attente d'impression et on procède à la conversion + modification adaptation profil impression

If PDFCreatorQueue.WaitForJob (10) Then
Set printJob = PDFCreatorQueue.NextJob

printJob.SetProfileByGuid ("DefaultGuid")
'printJob.SetProfileSetting "Name", "AIE"
'printJob.SetProfileByGuid "AIE"
printJob.SetProfileSetting "OpenViewer", "False"
printJob.SetProfileSetting "OpenViewer", "False"
printJob.SetProfileSetting "OutputFormat", "Pdf"
printJob.SetProfileSetting "ShowQuickActions", "False"
printJob.SetProfileSetting "ShowProgress", "False"
'printJob.SetProfileSetting "SkipPrintDialog", "True"
printJob.SetProfileSetting "ShowAllNotifications", "False"

printJob.ConvertTo (fullPath)


'MsgBox "Releasing the object"
'On Error GoTo erreur
'PDFCreatorQueue.ReleaseCom

'End    

End if

On Error Resume Next
PDFCreatorQueue.ReleaseCom

End Function

This code is used in a business application using vscript for custom actions.

I don't use the browser application for printing.

Thank by advance,

Regards,

Alexandre.

Hi,

PDFCreator.PrintFile will just look up and execute the command for printing html files in your registry.
You will need to replace this part and instead directly call a browser executable or library for silently printing html files. For Chrome there seems to be a --kiosk-printing switch to do this.

Best regards

Robin