网页导出Pdf,样式不变
Posted blogcore
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了网页导出Pdf,样式不变相关的知识,希望对你有一定的参考价值。
public static void htmlToPdf(string urlPath, string fileName)
{
string path = AppDomain.CurrentDomain.BaseDirectory;
string savepath = fileName;
string url = urlPath;
try
{
if (!string.IsNullOrEmpty(url) || !string.IsNullOrEmpty(savepath))
{
Log("PDFHelper_path_null_NEW:" + HttpContext.Current.Request.PhysicalApplicationPath + "wkhtmltopdf.exe");
var p = new Process();
string dllstr = HttpContext.Current.Server.MapPath("~/wkhtmltopdf.exe"); // path + "wkhtmltopdf.exe";
if (System.IO.File.Exists(dllstr))
{
p.StartInfo.FileName = dllstr;
p.StartInfo.Arguments = " "" + url + "" "" + savepath + """;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
}
}
}
catch (Exception ex)
{
Log(ex.Message+ex.StackTrace);
throw new Exception(ex.ToString());
}
}
以上是关于网页导出Pdf,样式不变的主要内容,如果未能解决你的问题,请参考以下文章