Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jul 11, 2018 3:43 pm

Hi
I am using spire.pdf dll for filling the pdf form now i have to fill image field with image which is comming in the form of binary data from database.
So please help me to bind binary data into image field.

suraj993
 
Posts: 1
Joined: Wed Jul 11, 2018 3:37 pm

Thu Jul 12, 2018 2:55 am

Dear suraj993,

Thanks for your inquiry.
Here is sample code for your reference:
Code: Select all
            PdfDocument doc = new PdfDocument(@"ImageFieldsample.pdf");
            PdfFormWidget formWidget = doc.Form as PdfFormWidget;
            for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
            {
                PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
               if (field is PdfButtonWidgetFieldWidget)
                {
                    PdfButtonWidgetFieldWidget bottonField = field as PdfButtonWidgetFieldWidget;
                    //get image data from your database
                    byte[] imageByte =  data
                    MemoryStream stream = new MemoryStream(imageByte);
                    //load the image in PdfImage
                    PdfImage image = PdfImage.FromStream(stream);
                    //set the buttom image
                    bottonField.SetButtonImage(image);                 
                }
            }
            doc.SaveToFile("14373.pdf");

If you still have the issue, please share us your input files(PDF and images) and the code you were using for further investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jul 16, 2018 3:57 am

Dear suraj993,

Greetings from E-iceblue.
Did the code I provided help you solve your issue ?
Could you please give us some feedback at your convenience ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF