0
I’m trying to put an image in the pdf, but it’s an error because Itextsharp’s Image class only accepts Uri, and what I have is an incoming stream that I’ve already converted to System.Drawing.Image.
public static Document GeraPdf(Stream stream)
{
Document doc = new Document(PageSize.A4);
doc.SetMargins(40, 40, 40, 80);
doc.AddCreationDate();
string caminho = @"C:\Users\ASUS\Desktop\eae.pdf";
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create));
doc.Open();
string dados = "";
System.Drawing.Image img1 = System.Drawing.Image.FromStream(stream);
Image ImagemPdf= Image.GetInstance(img1,ImageFormat.Jpeg);//Aqui esta o Erro
Paragraph paragrafo = new Paragraph(dados, new Font(Font.NORMAL, 14));
paragrafo.Alignment = Element.ALIGN_JUSTIFIED;
paragrafo.Add("TESTE TESTE TESTE");
doc.Add(paragrafo);
doc.Close();
return doc;
}