Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

How to print image (HTML converted to image) silently through webbrowser control

$
0
0

Because I fail to print document with its background colors in webbrowser because of the IE limitations.

I want to print HTML converted to image silently in webbrowser, but it prints empty page!

I create a converter method :

 public MemoryStream ConvertHtmlToImage(string html)
        {
            Bitmap m_Bitmap = new Bitmap("image");
            HtmlRender.RenderGdiPlus(Graphics.FromImage(m_Bitmap),
                                                   html);
            MemoryStream memoryStream = new MemoryStream();

            m_Bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
            return memoryStream;

        }

MemoryStream HtmlImage = ConvertHtmlToImage(processedDocTest);
webBrowserTest = new System.Windows.Forms.WebBrowser();
webBrowserTest.DocumentStream = HtmlImage; //Assign the image as a stream 

  private void btn_print_test_Click(object sender, EventArgs e)
        {
            if (Common.TestPrinter != null && !string.IsNullOrEmpty(Common.TestPrinter))
            {
                SetupPage();
                SetDefaultPrinter(Common.TestPrinter);
            }
            PrinterSettings settings = new PrinterSettings();
            defaultPrinter = settings.PrinterName;

            if (Common.TestPrinter == defaultPrinter)
            {
                PrintTest();
            }
            else
            {
                ResetSetupPage();
                Environment.Exit(1);
            }
        }
    }

Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>