It looks like you're new here. If you want to get involved, click one of these buttons!
Hi All:
I am trying to convert a HTML document into pdf using the PDFCreator, however, it never creates the document silently like it does with a word document. I receive the Print dialogue box prompt which only converts the html document when i press the Print button. I would like to convert the html document without receiving the Print dialogue. Any help would be greatly appreciated. List below is the code I am currently using...
Dim cConverter As clsPDFCreator
Dim cConverterOptions As clsPDFCreatorOptions
Dim DefaultPrinter As String
Set cConverter = New clsPDFCreator
Set cConverterOptions = New clsPDFCreatorOptions
Set cConverter.cOptions = cConverterOptions
If cConverter.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can not Initialise PDF Converter", vbCritical, "PDF Conversion Error"
Exit Function
End If
With cConverter
DefaultPrinter = .cDefaultPrinter
.cOption("PDFDisallowCopy") = 1
.cOption("PDFDisallowModifyContents") = 1
.cOption("PDFDisallowModifyAnnotations") = 1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPath
.cOption("AutosaveFilename") = sFNme
.cOption("AutosaveFormat") = 0
.cDefaultPrinter = "PDFCreator"
.cClearCache
.cPrintFile (sName) <-- when the code gets to this line it opens the Print Dialogue - I would like it to convert the file here without the Print dialogue prompt
.cPrinterStop = False
End With
Sleep 1000
With cConverter
.cPrinterStop = True
.cDefaultPrinter = DefaultPrinter
Sleep 200
.cClose
End With
Sleep 2000 ' Wait until PDFCreator is removed from memory
Set cConverterOptions = Nothing
Set cConverter = Nothing
I don't know how pdf creator implements this functionality in detail but in general it is the job of the printing application to display or not to display this dialogue.
I think at last there is (usually) a command line like that:
notepad /P test.txt
But not in this case. Have a look at:
HKEY_CLASSES_ROOT\htmlfile\shell\printto\command
"C:\WINDOWS\system32\rundll32.exe" "C:\WINDOWS\system32\mshtml.dll",PrintHTML %1 %2 %3 %4
and
HKEY_CLASSES_ROOT\htmlfile\shell\Print\command
"C:\WINDOWS\system32\rundll32.exe" "C:\WINDOWS\system32\mshtml.dll",PrintHTML %1
As you can see rundll.exe is invoked and calls a method in mshtml.dll .
Now it's your turn to find a program, which is registrated with the *.html, *.htm, ... extensions and which modifies the keys shown above.
Or - another solution - find a program with a command switch to print html - files:
1) set pdf-creator as the default printer
2) shellexec the application with the appropriate print-command line.
Good luck!
Yours sincerely RE
Hi Rillke: Thnaks very much for your response. It was easier to create a console application to find the window and click the print button. Works everytime
Hi thomasrc,
I was wondering if you could share your code for how to check and click on print button. I am having same issue only difference is I am Winnovative tool for conversion.
You help will be highly appriciated.
Thanks in advance