Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add Image to PDF from Visual Basic

1,342 views
Skip to first unread message

Allan_S...@adobeforums.com

unread,
Jul 13, 2004, 3:46:10 PM7/13/04
to
I am trying to insert images(jpg, bmp whatever) into a filled out PDF form, from Visual Basic 6. I have the SDK, but can not figure out how to do it. Has anybody done this?

Allan_S...@adobeforums.com

unread,
Jul 13, 2004, 6:59:57 PM7/13/04
to
Donn,
You are a life saver, your suggestion worked very well. However, BMP files will not load into the button programmatically. No big deal, I converted them to PDFs. Thanks.

j_mo...@adobeforums.com

unread,
Jul 17, 2004, 8:31:32 AM7/17/04
to
VISUAL BASIC 6:

Could you please give me your code example of that specific process:

-convert BMP logo files into PDF (you say that's a necessary step)
-insert that image logo into a PDF file at (x,y).

Thank's a lot.

j_mo...@adobeforums.com

unread,
Jul 21, 2004, 7:44:59 AM7/21/04
to
Dear Donn,

Even if the code seems to be good, I could not see the image...
Thank you for any precious help.

' AddImageInsidePDF.vbp
'
' - The application shows how to insert an image inside PDF document

'
' - To run the sample:
'
' 1. Copy the FormsAutomation.pdf and MyImage.pdf files into the
' C:\ directory.
' 2. Run the sample and click on the Create Fields button. The
' sample will open the PDF in Acrobat and add form fields
' (image) to it.

Dim formApp As AFORMAUTLib.AFormApp
Dim acroForm As AFORMAUTLib.Fields
Dim field As AFORMAUTLib.field
Dim bOK As Boolean
Dim avDoc As CAcroAVDoc
Dim pdDoc As CAcroPDDoc

Private Sub CreateFieldsButton_Click()

'Set the mouse icon to display an hourglass
Screen.MousePointer = 11

'Disable the create fields button
CreateFieldsButton.Enabled = False

'Update the status box
StatusBox.Text = "Opening PDF Document..."

' Open the sample PDF file
Set avDoc = CreateObject("AcroExch.AVDoc")
'bOK = avDoc.Open("C:\FormsAutomation.pdf", "Forms Automation Demo")

'If everything was OK opening the PDF, we now instantiate the Forms
'Automation object.
If (bOK) Then
Set formApp = CreateObject("AFormAut.App")
Set acroForm = formApp.Fields
Else
Set avDoc = Nothing
MsgBox "Failed to open PDF Document. Aborting..."
End
End If

'Update the status box
StatusBox.Text = "Creating Form Fields..."

'Create a button that represents an image
Set field = acroForm.Add("Logo Button", "button", 0, 175, 50, 225, 100)
field.BorderStyle = "beveled"
'field.Highlight = "push"
field.IsReadOnly = True
field.SetButtonIcon "N", "c:\MyImage.pdf", 0

'Update the Status box.
StatusBox.Text = "Fields have been added successfully."

'****************
'This section converts a AVDoc to a PDDoc. Then we use PDDoc.Save to
'save the PDF since there isn't a viewer level method to save an AVDoc.

'These lines are commented out to provide user feedback
'If present, no doc is visible and original form is changed
'so it isn't obvious what the sample did, and it doesn't work
'twice in a row.
'It's best to have Acrobat open and visible to see form creation
'''''''''
Set pdDoc = avDoc.GetPDDoc
'bOK = pdDoc.Save(1, "C:\FormsAutomation_result.pdf")
If bOK = False Then
MsgBox "Unable to Save the PDF file"
End If

' Close the AVDoc
avDoc.Close (False)
'''''''''
'End provide User Feedback
'****************

CleanUp:
'Change the mouse pointer to display normal cursor and enable the Exit button
Screen.MousePointer = 0

'Enable the create fields button
CreateFieldsButton.Enabled = True
End Sub

Private Sub ExitButton_Click()
' End the program
End

End Sub

l_b...@adobeforums.com

unread,
Jul 30, 2004, 7:47:50 PM7/30/04
to
Hi j molina

Did you ever get a solution to your problem of not being able to see the image on button? I am having the same probelm and would like to know if you were able to solve it.

TIA

j_mo...@adobeforums.com

unread,
Aug 3, 2004, 2:09:50 AM8/3/04
to
Dear TIA,

I have not resolved this little problem yet. But, be sure that the solution is near following my point of view.
If you find something, please let me know.

Regards,

0 new messages