Page 1 of 1

Cannot Print .html files without displaying the print dialog

Posted: Thu Mar 22, 2012 1:19 pm
by chedges
Hello,

I'm having some issues printing .htm / html files without the printer dialog being displayed and the user having to click the print button.
If I print a different file type e.g .txt or .jpg the print process completes successfully without any user interation.

Is there something special that needs to be done to allow html files to print without displaying the print dialog?

btw, I'm using the COM object in Delphi

Re: Cannot Print .html files without displaying the print di

Posted: Fri Apr 20, 2012 2:23 pm
by Sergio
YES its posible print HTML Files without showing system print dialog.

You will need to install PrintHTML.exe file in your server and call it from code. You can download here: http://www.printhtml.com/

STEP 1: Set printing settings, such as, Output File Name, Author, Subject, etc.
STEP 2: Call PrintHTML.exe

Sample (VB.NET):

Try
Dim objPDF_Settings As New Bullzip.PdfWriter.PdfSettings

'// STEP 1
With objPDF_Settings
.PrinterName = "Bullzip PDF Printer"
.SetValue("Author", "xxx")
.SetValue("Title", "xxx")
.SetValue("Subject", "xxx")
.SetValue("Output", [YOUR_PDF_PATH_FILE_NAME])
.SetValue("ShowSettings", "never")
.SetValue("ShowSaveAS", "never")
.SetValue("ShowProgress", "no")
.SetValue("ShowProgressFinished", "no")
.SetValue("ShowPDF", "no")
.SetValue("ConfirmOverwrite", "no")
.SetValue("RememberLastFileName", "no")
.SetValue("RememberLastFolderName", "no")
.SetValue("SuppressErrors", "no")
.SetValue("Linearize", "yes")

.WriteSettings()

'/* STEP 2
Dim objProcess As New System.Diagnostics.Process

With objProcess
.StartInfo.FileName = "PrintHTML.exe"
.StartInfo.Arguments = "file=" & Chr(34) & [YOUR_HTML_FILE_NAME] & Chr(34) & " " & _
"printername=" & Chr(34) & "Bullzip PDF Printer" & Chr(34)
.Start()
.WaitForExit()
.Close()
End With

End With

Catch ex As Exception
End Try

I hope this solve your problem

Regards from Spain