Chr*_*ruS 6 html pdf converters
我想将 HTML 页面转换为 PDF。有多种选择,但它们都存在一些问题。
PDFCreator(太麻烦)wkhtmltopdf(低质量)PhantomJS(低质量)也许我可以使用复杂的解决方案?PhantomJS要通过 进行打印PDFCreator,或者提高 的质量wkhtmltopdf,或者可能是其他什么?
也许你可以尝试使用Amyuni WebkitPDF。它不是开源的,但可以免费用于商业用途,并且可以从 C# 中使用。
文档中的 C# 示例代码:
static private void SaveToFile(string url, string file)
{
// Store the WebkitPDFContext returned value in an IntPtr
IntPtr context = IntPtr.Zero;
// Open the URL. The WebkitPDFContext returned value will be stored in
// the passed in IntPtr
int ret = WKPDFOpenURL(url, out context, 0, false);
if (ret == 0)
{
// if ret is 0, then we succeeded in opening the URL.
// Save the result as PDF to a file. Use the obtained context value
ret = WKPDFSaveToFile(file, context);
}
if (ret != 0)
Debug.WriteLine("Failed to run SaveToFile on '" + url + "' to generate file '" + file + "'");
// Make sure to close the WebkitPDFContext because otherwise the
// internal PDFCreator as well as other objects will not be released
WKPDFCloseContext(context);
}
Run Code Online (Sandbox Code Playgroud)
通常的免责声明适用。
| 归档时间: |
|
| 查看次数: |
6129 次 |
| 最近记录: |