We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Field Image

Good day,

  How can assign value to my Image/Button field created from Adobe Acrobat DC Pro, I don't see corresponding field in Syncfusion.

Thank you.

1 Reply

SK Surya Kumar Syncfusion Team August 19, 2019 10:45 AM UTC

Hi Martin Sato, 

Greetings from Syncfusion. 

As per the PDF specification, there is no separate form field for adding images. As a workaround we can achieve your requirement by creating new button field and replacing it to the existing one, please refer the below code for further details: 

PdfLoadedDocument loadedDocument = new PdfLoadedDocument( pdfStream, true); 
PdfLoadedForm loadedForm = loadedDocument.Form; 
for (int i = 0; i < loadedForm.Fields.Count; i++) 
Console.WriteLine(loadedForm.Fields[i].Name + " "+i); 
if (loadedForm.Fields[i] is PdfLoadedButtonField) 
PdfLoadedButtonField loadedField = loadedForm.Fields[i] as PdfLoadedButtonField; 
//Create new field and clone its parameters 
PdfButtonField field = new PdfButtonField(loadedField.Page, loadedField.Name); 
field.Bounds = loadedField.Bounds; 
field.BorderColor = loadedField.BorderColor; 
field.BorderStyle = loadedField.BorderStyle; 
field.BorderWidth = loadedField.BorderWidth; 
PdfImage image = new PdfBitmap(imageStream); 
//Add image to the appearance stream of the created field 
field.Appearance.Normal.Graphics.DrawImage(image, new RectangleF(0,0, field.Appearance.Normal.Width, field.Appearance.Normal.Height) ); 
// remove the existing field 
//Add the new field 
MemoryStream ms = new MemoryStream(); 

Let us know if you need any further information. 

Surya Kumar 

Live Chat Icon For mobile
Up arrow icon