[英]iTextSharp writer.AddDirectImageSimple throws exception
What could be the problem for writer to throw an error, when the code seems correct? 当代码看起来正确时,编写器抛出错误可能是什么问题? Image also exists.
图像也存在。
var img2 = iTextSharp.text.Image.GetInstance("C:\\2.bmp");
writer.AddDirectImageSimple(img2);
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at iTextSharp.text.pdf.PdfWriter.AddDirectImageSimple(Image image, PdfIndirectReference fixedRef)
at iTextSharp.text.pdf.PdfWriter.AddDirectImageSimple(Image image)
That's not how you add an image to a PDF. 这不是将图像添加到PDF的方式。 The method
AddDirectImageSimple
is to be usd by specialists only. 方法
AddDirectImageSimple
仅可由专业人员使用。
What is your purpose when you use that method? 使用该方法的目的是什么? If you want to add an
Image
to the document, you should use: 如果要将
Image
添加到文档,则应使用:
document.Add(img2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.