From: sug on 2 Dec 2005 10:15 Hello, I have a windowless application that runs as a process. This process needs to support HTML printing functionality. What are the possible options to print HTML file from a process? ShellExecute with option "printto" doesn't work for me because it pops up the printer dialog and my process can not have UI. Can I create an object of WebBrowser and use method ExecWB from a window-less, console application? My main task is to be able to print HTML files. Is there any library available for this? Any suggestions would be appreciated. Thanks. Sug
From: Alex Blekhman on 2 Dec 2005 12:36 sug wrote: > Hello, > > I have a windowless application that runs as a process. > This process needs to support HTML printing > functionality. What are the possible options to print > HTML file from a process? Here's the info how to print with WebBrowser control: "Printing Pages with the WebBrowser Control" http://msdn.microsoft.com/workshop/browser/webbrowser/webbrowser.asp?frame=true#Print_page Here's working sample: "How to print XSL formatted XML in MFC using IWebBrowser2" http://groups.google.com/group/comp.os.ms-windows.programmer.win32/msg/ad4770fd6ae1e2b6 It prints XML file, but it doesn't matter. You can print HTML files exactly the same. HTH Alex
From: David Ching on 2 Dec 2005 13:11 "sug" <zamu23(a)yahoo.com> wrote in message news:1133536558.036622.58280(a)z14g2000cwz.googlegroups.com... > Hello, > > I have a windowless application that runs as a process. This process > needs to support HTML printing functionality. What are the possible > options to print HTML file from a process? > > ShellExecute with option "printto" doesn't work for me because it > pops up the printer dialog and my process can not have UI. > > Can I create an object of WebBrowser and use method ExecWB from a > window-less, console application? > > My main task is to be able to print HTML files. Is there any library > available for this? > Try creating a hidden window that has a WebBrowser control embedded inside. Print using the WebBrowser control. In order to host the hidden window, you need a message pump. So you can't have a console application. But you can create an MFC .exe and just not show any window, which should act the same. BTW, it is assuming a lot that the default printer options are the desired ones... are you sure you don't want to show the printer dialog to let the user set which printer, Portrait/Landscape, etc? -- David http://www.dcsoft.com
From: MFC programmer on 2 Dec 2005 16:06 I'm fairly certain this cannot be done because the browser requires you to go through a print dialog box. This is a security measure so that a malicious website can't kickoff endless prints because the user would have to OK the print via that dialog. That dialog is a child of the browser window and it would have to be displayed and OK'd by end user to run the job (it might not even be visible if the browser is invisible?) There was a command IE allowed printing directly without displaying that dlg but it was depricated as a security measure and the dialog box is always displayed. If I was you I would reconsider using the web browser as a print engine unless you are willing to put up with several problems. I worked on app that used that approach for 1 release and then scrapped it and redid our reports using crystal reports (although I'm not necessarily recommending that unless you are needing a very heavy and feature rich tool). besides the dialog box thing I mentioned above there were other problems: shares settings with IE (such as headers/footers/etc.) which can cause unexpected results. undocumented approaches which are fragile (such as editing registry to change headers and footers etc.) lack of total control over page breaks spacing etc. html pagination features were ignored by browser very large jobs wold just be truncated (the browser would not load all of a very large html doc into memory).
From: David Ching on 2 Dec 2005 22:09 "MFC programmer" <riverross(a)gmail.com> wrote in message news:1133557615.445633.302430(a)g49g2000cwa.googlegroups.com... > I'm fairly certain this cannot be done because the browser requires you > to go through a print dialog box. This is a security measure so that a > malicious website can't kickoff endless prints because the user would > have to OK the print via that dialog. That dialog is a child of the > browser window and it would have to be displayed and OK'd by end user > to run the job (it might not even be visible if the browser is > invisible?) There was a command IE allowed printing directly without > displaying that dlg but it was depricated as a security measure and the > dialog box is always displayed. > > If I was you I would reconsider using the web browser as a print engine > unless you are willing to put up with several problems. I worked on > app that used that approach for 1 release and then scrapped it and > redid our reports using crystal reports (although I'm not necessarily > recommending that unless you are needing a very heavy and feature rich > tool). besides the dialog box thing I mentioned above there were other > problems: > > shares settings with IE (such as headers/footers/etc.) which can cause > unexpected results. > > undocumented approaches which are fragile (such as editing registry to > change headers and footers etc.) > > lack of total control over page breaks spacing etc. > > html pagination features were ignored by browser > > very large jobs wold just be truncated (the browser would not load all > of a very large html doc into memory). > All these issues can be avoided by using an embedded IE browser control and a "print template" which is supported in IE 5.5 or above. I've used a print template to print directly to the printer (avoiding the Print Options dialog box), and to specify my own headers and footers, that do not get used by Internet Explorer itself. -- David http://www.dcsoft.com
|
Next
|
Last
Pages: 1 2 Prev: URLDownloadToFile Next: ON_MESSAGE change from VC++ 6.0 to VC++ .net 2003 ? |