2013-04-10 38 views
0

我需要打印用c#代碼創建的html文件。我有一個過程來完成它:在c#中打印htm文件,無需頁頭和頁腳

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

打印的文檔包含默認標題(頁頭10F X)和默認頁腳(文件URL)我。怎麼可以打印HTML文件沒有這個頁眉和頁腳?

回答

0

如果找到解決方案,我保存帶有「.doc」擴展名的html文件,然後打印doc文件。 System.IO.File.WriteAllText(「1.html」,printHtml,Encoding.UTF8);
Process printjob = new Process();
printjob.StartInfo.FileName = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly()的GetName()基本代碼。)+ 「\ 1.HTML」
printjob.StartInfo.UseShellExecute = TRUE;
printjob.StartInfo.Verb =「print」;
printjob.StartInfo.CreateNoWindow = true;
printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printjob.Start();