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) 回答1: That's not how