DynaPDF Picture on Form PDF

  1. 9 months ago

    Victor M

    8 Dec 2018 Pre-Release Testers

    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.

    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.

  2. Christian S

    8 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

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

    We could check what data is there.

  3. Victor M

    9 Dec 2018 Pre-Release Testers

    @ChristianSchmitz patient_photo

    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

  4. Christian S

    9 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    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.

  5. Christian S

    9 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    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.

  6. Victor M

    9 Dec 2018 Pre-Release Testers
    Edited 9 months ago

    @ChristianSchmitz f = pdf.FindFieldAnsi(

    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 ..

  7. Christian S

    10 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Answer Germany

    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.

  8. Victor M

    11 Dec 2018 Pre-Release Testers

    @ChristianSchmitz 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.

    Can someone help me with an example?
    Please......

  9. Christian S

    16 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    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.

  10. Christian S

    19 Dec 2018 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    here is an example 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

    Seems to work here.

or Sign Up to reply!