Hello,
I'm having difficulty preventing the print dialog being diaplayed when trying to convert .htm files into Pdfs
I can print images, textfiles and various other filetypes without the print dialog being displayed but I cannot get html pages to print without
requiring user interaction to click the ok button.
When I print html files, the print dialog is opened and the Bull Printer is selected so it only needs the user to click ok but I really need this work without
any dialogs being displayed. Are there some special settings required to get them to print without it displaying the dialog?
Here are the settings in using for the COM Object. It's written in Delphi. (note: the below is not the complete code)
BullPDF := CreateOLEObject(UTIL_PROGID);
settings := CreateOLEObject(SETTINGS_PROGID);
settings.printername := BullPDF.defaultprintername;
lPrinterName := settings.printername;
settings.SetValue('Output', aOutputFilename);
settings.SetValue('ConfirmOverwrite', 'no');
settings.SetValue('ShowSaveAS', 'never');
settings.SetValue('ShowSettings', 'never');
settings.SetValue('ShowProgress', 'no');
settings.SetValue('ShowProgressFinished', 'no');
settings.SetValue('ShowPDF', 'no');
settings.SetValue('RememberLastFileName', 'no');
settings.SetValue('RememberLastFolderName', 'no');
settings.SetValue('StatusFile', statusfilename);
settings.SetValue('StatusFileEncoding', 'unicode');
BullPDF.PrintFile(InputFilename, lPrinterName);
Printing .htm files always displays the print dialog?
Moderator: jr
Re: Printing .htm files always displays the print dialog?
YES It is posible to print HTML files without showing system print dialog!.
If you want to print HTML files , you need to install, in server, PrintHTML.exe program.
This program is FREE and you can download here: www.printhtml.com
The printing for HTML file is made in two steps:
- STEP 1:
Configure your code to set Settings of printing, but DO NOT CALL PdfUtil.PrintFile method. Only set Settings!
- STEP 2:
Call PrintHTML.exe command line program with correct parameters
Sample code:
Try
Dim objPDF_Settings As New Bullzip.PdfWriter.PdfSettings
'// STEP 1: Save Printer Settings
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: Call PrintHTML.exe
Dim objProcess As New System.Diagnostics.Process
With objProcess
.StartInfo.FileName = "PrintHTML.exe"
.StartInfo.Arguments = "file=" & Chr(34) & [YOUR_HTML_PATH_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
If you want to print HTML files , you need to install, in server, PrintHTML.exe program.
This program is FREE and you can download here: www.printhtml.com
The printing for HTML file is made in two steps:
- STEP 1:
Configure your code to set Settings of printing, but DO NOT CALL PdfUtil.PrintFile method. Only set Settings!
- STEP 2:
Call PrintHTML.exe command line program with correct parameters
Sample code:
Try
Dim objPDF_Settings As New Bullzip.PdfWriter.PdfSettings
'// STEP 1: Save Printer Settings
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: Call PrintHTML.exe
Dim objProcess As New System.Diagnostics.Process
With objProcess
.StartInfo.FileName = "PrintHTML.exe"
.StartInfo.Arguments = "file=" & Chr(34) & [YOUR_HTML_PATH_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
Re: Printing .htm files always displays the print dialog?
I was able to do it without using the PrintHtml.exe. Please see my other post.
var pdfSettings = new PdfSettings();
pdfSettings.PrinterName = "Bullzip PDF Printer";
pdfSettings.SetValue("SavePath", "C:\\Users\\manas_p\\Documents\\");
pdfSettings.SetValue("Output", "C:\\Users\\c_manas_p\\Documents\\test.pdf");
pdfSettings.SetValue("FileName", "test.pdf");
pdfSettings.SetValue("ShowSaveAS", "never");
pdfSettings.SetValue("ShowSettings", "never");
pdfSettings.SetValue("ShowProgress", "no");
pdfSettings.SetValue("ShowProgressFinished", "no");
pdfSettings.SetValue("ShowPDF", "no");
pdfSettings.SetValue("ConfirmOverwrite", "no");
pdfSettings.SetValue("RememberLastFileName", "no");
pdfSettings.SetValue("Linearize", "yes");
pdfSettings.SetValue("RememberLastFolderName", "no");
pdfSettings.SetValue("RememberLastFileName", "no");
pdfSettings.WriteSettings(true);
formBrowser.PrintBrowser(); //formBrowser is a browser control of type System.Windows.Forms.WebBrowser used in WPF in my case
Hope this helps.
Manas
var pdfSettings = new PdfSettings();
pdfSettings.PrinterName = "Bullzip PDF Printer";
pdfSettings.SetValue("SavePath", "C:\\Users\\manas_p\\Documents\\");
pdfSettings.SetValue("Output", "C:\\Users\\c_manas_p\\Documents\\test.pdf");
pdfSettings.SetValue("FileName", "test.pdf");
pdfSettings.SetValue("ShowSaveAS", "never");
pdfSettings.SetValue("ShowSettings", "never");
pdfSettings.SetValue("ShowProgress", "no");
pdfSettings.SetValue("ShowProgressFinished", "no");
pdfSettings.SetValue("ShowPDF", "no");
pdfSettings.SetValue("ConfirmOverwrite", "no");
pdfSettings.SetValue("RememberLastFileName", "no");
pdfSettings.SetValue("Linearize", "yes");
pdfSettings.SetValue("RememberLastFolderName", "no");
pdfSettings.SetValue("RememberLastFileName", "no");
pdfSettings.WriteSettings(true);
formBrowser.PrintBrowser(); //formBrowser is a browser control of type System.Windows.Forms.WebBrowser used in WPF in my case
Hope this helps.
Manas