iTextSharp writer.AddDirectImageSimple抛出异常

时间:2015-06-28 02:20:04

标签: c# image pdf itextsharp

当代码看起来正确时,编写器抛出错误可能会出现什么问题?图像也存在。

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)

1 个答案:

答案 0 :(得分:0)

这不是您如何将图像添加到PDF中。方法(GameObject)Resources.Load("Ethan", typeof(GameObject)) 仅供专家使用。

使用该方法时,您的目的是什么?如果要在文档中添加AddDirectImageSimple,则应使用:

Image
相关问题