0
我有問題,當我打印的html文件,我已經試過DOC,XLS和TXT文件,它們完美地工作,但是當我給HTML文件它爲我打印對話框和我有選擇ghostscript打印機才能工作。將HTML轉換成PS使用Ghostscript C#
我的代碼是:
[DllImport("Winspool.drv")]
private static extern bool SetDefaultPrinter(string printerName);
[ValidateInput(false)]
public ActionResult CreatePdf(string file , string html)
{
SetDefaultPrinter("Ghostscript");
Process process1 = new Process();
if (html != null && html != "")
{ process1.StartInfo.FileName = "example.html"; }
else
{ process1.StartInfo.FileName = file; }
process1.EnableRaisingEvents = true;
process1.StartInfo.Verb = "print";
process1.StartInfo.Arguments = "\"Ghostscript PDF\"";
process1.StartInfo.WorkingDirectory = Server.MapPath("~" + "/Export");
process1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process1.StartInfo.CreateNoWindow = true;
process1.Start();
try
{
process1.WaitForExit();
}
catch (InvalidOperationException) { }
process1.Dispose();
}
這應該改變我的output.ps文件,然後我用它來製作PDF文件,完美的作品,我只是需要做這項工作的html文件。
我跟着這兩個例子:
編輯: 我需要爲了得到從HTML PDF文件這個converstion,發現wkhtmltopdf最適合我的。