Server Side, Get from Raw HTML, HTML Formatted and then to Printer
Hello,
This is my situation. I have to run a large number of reports that take a while to print and the printed version needs to be exactly like the client side displayed version. Because of the time length required to print all the reports, I want to shift the process to the server which will handle the printing instead of the client( No client side interation besides launching the printing thread. ) I have searched the web for an answer or help thus far I have not come up with much to get from formatted hmtl on the server to a printer.
I don’t have the time to write my method to handle all the formatting of the html so I was hoping to find a more practical solution.
I found a number of VB developers using a Browser approach:
They would use the mshtml.DLL & SHDocVw.DLL (Windows/System32 directory) to create a browser and then run the ExecWB method to print.
1) Created the AxSHDocVw.DLL out of SHDocVw.DLL using AxImp.exe.
2) Added the references mshtml.DLL and AxSHDocVw.DLL.
3) Here is the snippet to create the browser( Orginal page I found this on: http://weblogs.asp.net/kaevans/archive/2003/02/25/2936.aspx )
InitializeComponent()
string url = "about:blank";
object o = System.Reflection.Missing.Value;
browser.Navigate ( url,ref o,ref o,ref o,ref o);
AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler handler =
new AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler
(this.browser_StatusTextChange);
browser.StatusTextChange += handler;
private void InitializeComponent()
{ System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.browser = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.browser)).BeginInit();
this.SuspendLayout();
//
// browser
//
this.browser.Enabled = true;
this.browser.Location = new System.Drawing.Point(16, 16);
this.browser.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("browser.OcxState")));
this.browser.Size = new System.Drawing.Size(344, 224);
this.browser.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(392, 302);
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.browser });
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.browser)).EndInit();
this.ResumeLayout(false);
}
private void browser_StatusTextChange
(object sender, AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEvent e)
{
mshtml.HTMLDocument doc = shtml.HTMLDocument)this.browser.Document;
doc.body.innerHTML = "
Replies
Know the answer? Post it — somebody with the same question will find it here.