早上好,
我正在尝试用Tuespechkin生成pdf文件,用的是html。它在本地运行得很好,但在生产中就不行了。
public static bool GeneratePDFFromHTMLPaysage(String full_path, String htmlContent, String baseUrl)
{
try
{
String content = "<!DOCTYPE html><html><head><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta charset='UTF-8' name='viewport' content='width=device-width, initial-scale=1'><title>Titre</title><link rel='stylesheet' type='text/css' href='https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css'><script type='text/javascript' src='https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js'></script></head><body><div class='container'>";
content = content + htmlContent;
content = content + "</div></body></html>";
full_path = full_path + ".pdf";
var document = new HtmlToPdfDocument
{
GlobalSettings =
{
ProduceOutline = true,
PaperSize = System.Drawing.Printing.PaperKind.A4, // Implicit conversion to PechkinPaperSize
Margins =
{
All = 0,
Unit = Unit.Centimeters
},
Orientation = GlobalSettings.PaperOrientation.Landscape
},
Objects = {
new ObjectSettings { HtmlText = content }
}
};
IConverter convert = new StandardConverter(
new PdfToolset(
new Win64EmbeddedDeployment(
new TempFolderDeployment())));
byte[] test = convert.Convert(document);
System.IO.File.WriteAllBytes(full_path, test);
return true;
}
catch (Exception e)
{
ErrorManager.Log(e.Message + "\n" + e.InnerException + "\n" + e.StackTrace);
return false;
}
}基本上,我尝试用32位替换64位,按照文档中的建议为部署指定一个静态路径(这样做会创建一个文件夹,在其中放置缺少的DLL,它在本地的行为与在生产中的行为相同,但只能在本地工作)。
我的应用程序是一个基本的windows应用程序,我只需从Debug或Release文件夹中复制文件来部署它:

正如您所看到的,我包含了wkhtmltox.dll,因此它自动部署在项目的根文件夹中,但也没有结果
**摘要:** .NET 4框架,windows应用程序,试图使用Tuespechkin,已经在生产环境中安装了visual C++ 2013,试图解决缺少dll的问题,以及许多与代码有关的东西
感谢您的关注,希望有一个解决方案
发布于 2020-12-17 23:24:37
嗯,似乎我的生产服务器太旧了(windows server 2003),这也许可以解释这个问题。
https://stackoverflow.com/questions/65339393
复制相似问题