Cannot Print .html files without displaying the print dialog

About the programming interface for the virtual PDF printer driver.

Moderator: jr

chedges
Posts: 2
Joined: Thu Mar 22, 2012 11:57 am

Cannot Print .html files without displaying the print dialog

Post 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
Sergio
Posts: 2
Joined: Fri Apr 20, 2012 12:57 pm

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

Post 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
Post Reply