으로 HTML을 PS로 변환합니다. html 파일을 인쇄 할 때 doc, xls 및 txt 파일을 시도했을 때 문제가 발생하지만 완벽하게 작동하지만 html 파일에 인쇄 대화 상자가 표시되면 작동하려면 고스트 스크립트 프린터를 선택하십시오.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();
}
이 난 그냥 html 파일에 대해이 작업을 할 필요가 완벽하게 작동 후 내가 pdf 파일을 만들기 위해 사용하는 내 output.ps 파일을 변경해야합니다.
나는이 2 예를 다음 :편집 : 내가 HTML에서 PDF 파일을 얻기 위해이 converstion이 필요하고, 그 wkhtmltopdf 가장 나에게 맞는 발견했다.