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最适合我的。