itextsharp adding image to existing pdf

后端 未结 2 1786
生来不讨喜
生来不讨喜 2020-12-21 11:06

i am trying to add an image using itextsharp but not having any luck there are a ton of tutorials for adding an image to a new pdf doc but not and existing pdf so the .add m

2条回答
  •  臣服心动
    2020-12-21 11:36

    I think you try the following adding it to bytes

            PdfReader reader = new PdfReader(pdfIn)
            FileStream fs = new FileStream(pdfOut, FileMode.Create);
            var stamper = new PdfStamper(reader, fs);
            var pdfContentByte = stamper.GetOverContent(1);
            iTextSharp.text.Image sigimage = iTextSharp.text.Image.GetInstance(bytes);
            sigimage.SetAbsolutePosition(100, 100);
            pdfContentByte.AddImage(sigimage);
    

提交回复
热议问题