【发布时间】:2022-02-18 18:25:25
【问题描述】:
在生成带有 IText 中图像的 PDF 时遇到问题。
我们能够使用 IText 生成文档的文本,但它不会拉动图像。
我们正在关注他们电子书中的文字https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-converting-html-to-pdf-with-pdfhtml/chapter-1-hello-html-to-pdf
有问题的代码如下:
void createPdf(string baseUri, string html, string dest)
{
ConverterProperties properties = new ConverterProperties();
properties.SetBaseUri(baseUri);
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create), properties);
}
据我们所知,问题在于字符串 baseUri
我们假设这是在 Visual Studio 中的 C# 项目中保存图像的目录,并且到目前为止使用以下内容作为字符串无济于事:
- /图片/
- /Images/NewLogo.png
- http://localhost:64070/Images/NewLogo.png
这些都没有生成 PDF 中的图像,任何帮助或建议将不胜感激。
【问题讨论】:
-
感谢您的回复。您能否通过父文件夹/更具体一些?
-
我们在解决方案下创建了一个名为 Images 的文件夹,用于存储要使用的图像。
-
以下内容可能会有所帮助:stackoverflow.com/questions/69210758/…
-
删除绒毛的编辑are fine;这个特殊的编辑也改进了标题(大写没有意义,标签不在标题中)。请不要进一步回滚
-
问题是用户删除了 IText,这个特定问题与 IText 相关