我想打印超过1个html文件,如果可能的话,每个文件的打印时间不止一次。 我看过MSDN教程https://msdn.microsoft.com/en-us/library/b0wes9a3(v=vs.85).aspx并尝试修改它:
// Add an event handler that prints the document after it loads.
webBrowserForPrinting.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler((sender, e) => PrintDocument(sender, e, file1copies));
// Set the Url property to load the document.
webBrowserForPrinting.Url = new Uri(args[1]);
webBrowserForPrinting.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler((sender, e) => PrintDocument(sender, e, file2copies));
webBrowserForPrinting.Url = new Uri(args[3]);
和我的方法:
private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e, int copies) {
if (webBrowserForPrinting.ReadyState != WebBrowserReadyState.Complete || webBrowserForPrinting.Url.Equals("about:blank"))
return;
try
{
for (int i = 0; i < copies; i++) {
((WebBrowser)sender).Print();
Console.WriteLine("Printing...");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
我每次只打印最后一个网址 我怎样才能使它发挥作用?