# Just how do I publish an HTML record from an internet solution?

I intend to publish HTML from a C# internet solution. The internet internet browser control is excessive, and also does not function well in a solution setting, neither does it function well on a system with really limited protection restraints. Exists any kind of type of free .NET collection that will sustain the printing of a standard HTML web page? Below is the code I have until now, which does not run effectively.

public void PrintThing(string document)
{
{
}
else
{
PrintDocument(document);
}
}

protected void PrintDocument(string document)
{
WebBrowser browser = new WebBrowser();
browser.DocumentText = document;
{
Application.DoEvents();
}
browser.Print();
}


This functions penalty when called from UI-type strings, yet absolutely nothing takes place when called from a service-type string. Transforming Print() to ShowPrintPreviewDialog() generates the adhering to IE manuscript mistake:

Mistake: dialogArguments.___IE_PrintType is void or otherwise an object.

LINK: res://ieframe.dll/preview.dlg

And also a tiny vacant print sneak peek dialog shows up.

0
2019-05-06 23:35:43
Source Share

You can publish from the command line making use of the adhering to :

rundll32.exe. % WINDIR% \ System32 \ mshtml.dll, PrintHTML. "% 1"

Where %1 is the documents course of the html documents to be published.

If you do not require to publish from memory (or can manage to contact the disk in a temperature documents) you can make use of :

using (Process printProcess = new Process())
{
string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
printProcess.StartInfo.FileName = systemPath + @"\rundll32.exe";
printProcess.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + fileToPrint + @"""";
printProcess.Start();
}

.

N.B. This only work with Windows 2000 and also over I assume.

0
2019-05-08 05:26:26
Source

I recognize that Visual Studio itself (at the very least in 2003 variation ) referrals the IE dll straight to provide the "Design View".

It might deserve checking into that.

Or else, I can not consider anything past the Web Browser control.

0
2019-05-07 17:36:39
Source