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.

Thu May 12, 2022 4:19 pm

Does Spire.PDF support loading images into form fields? If so, could you point me to the documentation or example code that shows how it works?

I'm looking specifically for something comparable the following code that we use with ActivePdf's PDF Toolkit library:

Code: Select all
PdfObject.ImageByteArray = image;
PdfObject.SetFormFieldData(field, "MEMORY", -996);


Additionally, they also provide support for loading an image from the filesystem into a form field, like this:
Code: Select all
PdfObject.SetFormFieldData(“fieldname”, “c:\pathtoimage\image.jpg”,-995)
(taken from ActivePdf documentation here: documentation.activepdf.com/toolkit/toolkit_api/index.htm#2a_toolkit/method_SetFormFieldData.html?Highlight=setformfielddata)

My preference is to not load from the filesystem, being that we pull the image from the database and work with it as a byte array in memory.

EDIT:
I've also looked into PdfSharp as an option. They have the following method for adding an image to a text field:
Code: Select all
PdfObject.AcroForm.Fields[field].CreateStream(image)

rick.caborn
 
Posts: 1
Joined: Thu May 12, 2022 4:10 pm

Fri May 13, 2022 9:58 am

Hello,

Thanks for your inquiry.

Spire.PDF does not support adding an image to a text field. We can only add image to a button field. Sorry for the inconvenience caused.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF