DynaPDF Picture on Form PDF

Hi,

Hello, I have an example of PDF form and I can write text in fields in the following way but I need to insert images, how can I insert an image in a PDF form?

Example:

f = pdf.FindFieldAnsi(“patient”) // Data string
if f>=0 then
call pdf.SetTextFieldValue(f, patient_name.text, “”, pdf.ktaLeft)
end if

I need:

f = pdf.FindFieldAnsi(“patient_photo”) // Picture form on PDF
if f>=0 then
call pdf.SetTextFieldValue(f, patient_photo, “”, pdf.ktaLeft)
end if

Thanks.

a picture form field?
Do you have a sample PDF with such a picture inside?

We could check what data is there.

thanks for the response, in the pdf form I have two fields, one text and another image type, I need to write send an image and the text to the fields, in your example I know how to send text but not images.

/// works for text
f = pdf.FindFieldAnsi(“patient”) // Data string
if f>=0 then
call pdf.SetTextFieldValue(f, patient_name.text, “”, pdf.ktaLeft)
end if

/// how do I write an image to the form
dim photo as picture to field form?

patient_photo_af_image

PDF Example form fields text and picture
https://www.dropbox.com/s/869wjcjiiujwgmk/medical.pdf?dl=0

Thanks Christian

Well, I just opened that PDF and don’t see anything about a picture. Just a text field and a big box.

Ah, in Acrobat Reader, we see something.
I’ll ask Jens about this.

Okay, looks like it’s a normal button with JavaScript, which imports the image.
DynaPDF can’t run the JavaScript itself.

And the field patient_photo_af_image is probably just the picture as text.

Hi, Friend in your example, you published the following:
https://www.monkeybreadsoftware.net/example-dynapdf-acroform-fillvalue.shtml

// a normal text field
// and a combo box field
// set radiobutton
// set an image ???

I need the example for an image …

Looks like, the image set is just assigned to UpImage property in DynaPDFFieldExMBS class.
So you can check the values there for the button field.

AddButtonImage may add the image to a button.

[quote=417314:@Christian Schmitz]Looks like, the image set is just assigned to UpImage property in DynaPDFFieldExMBS class.
So you can check the values there for the button field.

AddButtonImage may add the image to a button.[/quote]

Can someone help me with an example?
Please…

Well, the function is defined like this:

AddButtonImage(BtnHandle as Integer, State as Integer, Caption as string, ImgFile as Folderitem) as boolean

to get button handle via FindField function by name, or just by index.
State is kbsUp, kbsdrown or kbsRollOver.
ImgFile is the folder item for an image file.

You can use example to show all form fields to learn how the image button is named.

here is an example code:

[code]dim pdf as new MyDynapdfMBS

pdf.SetLicenseKey “Lite” // For this example you can use a Lite, Pro or Enterprise License

dim outFile as folderitem = SpecialFolder.Desktop.Child(“Combine PDF files.pdf”)

if outFile = nil then Return

call pdf.CreateNewPDF(outFile)

dim flags as integer = Bitwise.BitOr(pdf.kifImportAsPage, pdf.kifImportAll)
call pdf.SetImportFlags(flags)

call pdf.openimportFile(SpecialFolder.Desktop.Child(“medical.pdf”), pdf.kptopen, “”)
call pdf.ImportPDFFile(1, 1.0, 1.0)
call pdf.CloseImportFile

dim fieldCount as integer = pdf.GetFieldCount
for i as integer = 0 to fieldCount-1
dim f as DynaPDFFieldExMBS = pdf.GetFieldEx(i)
if f.FieldType = pdf.kftButton then
// button found
call pdf.AddButtonImage(i, pdf.kbsUp, “”, SpecialFolder.Desktop.Child(“test.jpg”))
call pdf.AddButtonImage(i, pdf.kbsDown, “”, SpecialFolder.Desktop.Child(“test.jpg”))
end if
next

call pdf.closefile
outFile.Launch[/code]

Seems to work here.