【发布时间】:2016-05-03 05:54:11
【问题描述】:
我正在尝试使用 EvoPdf 库(演示版)。我有一个带有图像完整路径的 html 字符串,例如:
finalString.Append(@"<img src='http://www.ladessertelocale.com/2618-home_default/tomate-bio-1-kg.jpg'/>");
我使用以下代码生成 pdf。生成包含所有内容的 pdf 文件,但生成的 pdf 中未显示图像。红色 x 显示在图像的位置。
HtmlToPdfConverter converter = new HtmlToPdfConverter{
LicenseKey = "",
HtmlViewerWidth = 1024,
PdfDocumentOptions = { PdfPageSize = PdfPageSize.A4, PdfPageOrientation = PdfPageOrientation.Portrait, InternalLinksEnabled = true }
};
byte[] outPdfBuffer = null;
outPdfBuffer = converter.ConvertHtml(finalString.ToString(), "");
return File(outPdfBuffer, "application/pdf");
我错过了什么吗?
【问题讨论】:
-
尝试将图像 src 更改为图像文件夹的相对路径。或者,您可以将图像渲染为 Data/URI Base 64 吗?
-
那行得通。谢谢!。我将图像 html 更改为下面(base64 字符串被截断)。 finalString.Append(@"");
标签: html-to-pdf evopdf