我需要打印我在c#代码中创建的html文件。我是通过一个过程完成的:
System.IO.File.WriteAllText("1.html",printHtml,Encoding.UTF8);
Process printjob = new Process();
printjob.StartInfo.FileName = "1.html";
printjob.StartInfo.UseShellExecute = true;
printjob.StartInfo.Verb = "print";
printjob.StartInfo.CreateNoWindow = true;
printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printjob.Start();
打印文档包含默认标题(第1页X)和默认页脚(文件网址)。如果没有此页眉和页脚,我可以打印html文件吗?
答案 0 :(得分:0)
如果找到解决方案,我用“.doc”扩展名保存了html文件,然后打印了doc文件。
System.IO.File.WriteAllText(“1.html”,printHtml,Encoding.UTF8);
处理printjob = new Process();
printjob.StartInfo.FileName = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly()。GetName()。CodeBase)+“\ 1.html”
printjob.StartInfo.UseShellExecute = true;
printjob.StartInfo.Verb =“print”;
printjob.StartInfo.CreateNoWindow = true;
printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
对PrintJob.start();