wkhtmltopdf アプリケーションを使用して、ASP.net MVC 2 でレンダリングされた HTML を PDF に変換し、標準ビューの代わりに PDF を表示して、印刷機能を向上させています。すべてがうまく機能し、マイナス 1 つのことがあります。Web サーバー上の MVC アプリケーションで wkhtmltopdf をプロセスとして実行すると、インストールされているバーコード フォントが PDF に表示されません。
プロセスのコードは次のとおりです。
public void HtmlToPdf(string url, string appPath)
{
string message = null;
// to build command argument
StringBuilder argument = new StringBuilder();
// input html file
string switches = "";
switches += "--print-media-type ";
switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 10mm --margin-left 10mm ";
switches += "--page-size Letter ";
switches += "--load-error-handling ignore ";
switches += "--username admin ";
switches += "--password pass ";
argument.Append(switches + " " + url + " " + "C:\\PDF\\temp.pdf");
// to call the exe to convert
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.FileName = "C:\\wkhtmltopdf\\wkhtmltopdf.exe";
p.StartInfo.WorkingDirectory = "C:\\wkhtmltopdf";
p.StartInfo.Arguments = argument.ToString();
p.Start();
p.WaitForExit();
message = p.StandardError.ReadToEnd();
if (string.IsNullOrEmpty(message))
{
message = p.StandardOutput.ReadToEnd();
}
else
{
System.Diagnostics.Debug.WriteLine(message);
}
}
HTMLをレンダリングするときにバーコードが表示されますが、wkhtmltopddfがPDFに変換するときにバーコードが表示されないため、バーコードが表示されない理由はよくわかりません。私の MVC アプリケーションの外で wkhtmltopdf を実行しても、正しく動作します。
-助けてくれてありがとう