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);
}
}
}