Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a defined field named "Account Holder signature" how can i place this image into that text field, currently i am using absolute position but its not setting it at the correct spot. I want to be able to add it using setfield.

Dim pdfReader As New PdfReader(strPdfTemplate)
Dim pdfStamper As New PdfStamper(pdfReader, New FileStream(strNewPdfFile, FileMode.Create))
Dim path As String

path = Server.MapPath("~\bin\mySig.bmp")
img.Save(path, System.Drawing.Imaging.ImageFormat.Bmp)
Dim sig As AcroFields = pdfStamper.AcroFields
Dim sigposition As AcroFields.FieldPosition = sig.GetFieldPositions("Account Holder Signature")(0)

Dim sigimg As iTextSharp.text.Image
If Not path = String.Empty Then
sigimg = iTextSharp.text.Image.GetInstance(path)
Dim position As iTextSharp.text.Rectangle = sigposition.position

sigimg.SetAbsolutePosition(position.Width, position.Height)
Dim bytContent As PdfContentByte

bytContent = pdfStamper.GetOverContent(1)
bytContent.AddImage(sigimg)

End If
pdfStamper.FormFlattening = True

' close the pdf
pdfStamper.Close()
pdfStamper.Dispose()
pdfReader.Dispose()

Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900