0

我需要打印在 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();

打印的文档包含默认页眉(X 页第 1 页)和默认页脚(文件 url)。如何打印没有此页眉和页脚的 html 文件?

4

1 回答 1

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 = "打印";
printjob.StartInfo.CreateNoWindow = true;
printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printjob.Start();

于 2013-04-12T19:21:07.643 回答