public void ShowPrintPreview()
 {
     WebBrowser x = new WebBrowser();
     x.CreateControl();
     x.Visible = false;
     try
     {
         x.Navigate(Url);
         x.ShowPrintPreviewDialog();
     }
     catch (System.Net.WebException y)
     {
         MessageBox.Show(y.Message);
     }
 }
        static void BuildFile(string fileName, string classFileName)
        {
            WebBrowser wBrowser = new WebBrowser();
            wBrowser.CreateControl();
            wBrowser.Navigate(new Uri(WebUI.ResultsWebServer.Uri, "ServicesList.aspx"));
            WebBrowserHelper.Wait(wBrowser);

            HtmlDocument doc = WebBrowserHelper.GetDocument(wBrowser);
            string template = wBrowser.DocumentText;

            GenerateDocument(wBrowser);
            int bodyidx = template.IndexOf("<body>");
            template = template.Substring(0, bodyidx);
            StringBuilder body = new StringBuilder(doc.Body.OuterHtml);
            body.Replace("FONT-SIZE: 8.25pt;", "");
            body.Replace("FONT-FAMILY: Tahoma;", "");
            body.Replace("MARGIN: -7px;", "");
            body.Replace("</BODY>", "<br><span style='color: gray;'>Generated by : " + FreeCL.RTL.ApplicationInfo.ProductName + ", version :"+ FreeCL.RTL.ApplicationInfo.ProductVersion + "</span></body>" );

            string result = template + body.ToString() + "\r\n</html>";
            FileStream fs = new FileStream(fileName, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            sw.Write(result);
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();

            fs = new FileStream(classFileName, FileMode.Create);
            string className = Path.GetFileNameWithoutExtension(classFileName);
            sw = new StreamWriter(fs, Encoding.BigEndianUnicode);
            sw.Write("import java.applet.*;\r\n\r\n");
            sw.Write("public class ");
            sw.Write(className);
            sw.Write(" extends Applet{\r\npublic String d(){\r\n");
            int i = 0;
            int cnt;
            StringBuilder substr;
            int var_num = 0;
            while(i < result.Length)
            {
                cnt = 16384;
                if(i + cnt > result.Length)
                    cnt = result.Length - i;
                substr = new StringBuilder(result.Substring(i, cnt));
                substr.Replace("\"", "\\\"");
                substr.Replace("\r", "\\r");
                substr.Replace("\n", "\\n");
                sw.Write("String s");
                sw.Write(var_num.ToString());
                    var_num++;
                sw.Write(" = ");
                sw.Write("\"" + substr.ToString() + "\";\r\n");
                i += 16384;
            }
            sw.Write("return ");
            for(i = 0; i < var_num; i++)
            {
                sw.Write("s");
                sw.Write(i.ToString());
                if(i + 1 < var_num)
                    sw.Write("+");
            }
            sw.Write(";\r\n}\r\n}");
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();
        }