直接将.aspx转换为.pdf

JCd*_*ney 11 pdf asp.net pdf-generation

我正在处理的项目要求我构建一个以HTML(.aspx)和PDF格式输出的报表.是否有可用的解决方案允许我将.aspx页面的输出提供给PDF生成实用程序?完全支持HTML和CSS将是理想的.

谢谢!

jle*_*jle 12

wkhtmltopdf会这样做....使用方法:

wkhtmltopdf http://www.google.com google.pdf
Run Code Online (Sandbox Code Playgroud)

这就对了.你可以去任何网页...甚至aspx.css比任何其他实用程序都支持得更好,因为它使用webkit html呈现引擎(Safari,Chrome).请享用

只需使用Process.Start就可以从.Net中使用单个.exe(7 mb)确保将exe复制到项目目录中,或者必须指定完整路径.例如:

static void HtmlToPdf(string website,string destinationFile)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "wkhtmltopdf.exe";
        startInfo.Arguments = website+" "+destinationFile;
        Process.Start(startInfo);
    }  
Run Code Online (Sandbox Code Playgroud)

我认为SSL是受支持的,但我认为双向SSL目前不会起作用.它是我见过的最好的单站HTML - > PDF工具.