vb->pdf creation(Examles)

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
soorajgs
Posts: 7
Joined: Tue Jun 24 2003

vb->pdf creation(Examles)

Post by soorajgs »

hi,
pls send me some examples which pass values from VB programs or CTD programs to PDF documents.
thanks
sooraj
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I didn't really get what is the sample you are looking for.

I will however post a sample that creates a pdf file add a text box and a field to it and retrieve information from a database to that field.

Please not that there is two ways to use the PDF Creator: Either by adding the component on the form and let the user see the pdf file or by creating an instance of the control programmatically and make all the steps (creation of the file, editing it, ect...) transparent to the user.

In the below sample the instance of the control is created programmatically.

Option Explicit
Dim pdf As New ACPDFCREACTIVEX.PDFCreactiveX

Private Sub Command6_Click()

With pdf

'Create a text object
.CreateObject acObjectTypeText, "text1"

'Position the text
.ObjectAttribute("text1", "Left") = 600
.ObjectAttribute("text1", "Top") = 600
.ObjectAttribute("text1", "Right") = 700
.ObjectAttribute("text1", "Bottom") = 700
.ObjectAttribute("text1", "Text") = " GETTING INFORMATION FROM A DATABASE"

'Set the data source to an Access file
.DataSource = "University.mdb"

'Set the main table
.DataTableOrView = "Majors"

'Create a field object
.CreateObject acObjectTypeField, "Field1"

'Position Field1
.ObjectAttribute("Field1", "Left") = 1000
.ObjectAttribute("Field1", "Top") = 1000
.ObjectAttribute("Field1", "Right") = 2000
.ObjectAttribute("Field1", "Bottom") = 1500


'Set the object value to be:
'the field CreditsRequired (( multiplied by (*) the field FeesInUSD))
.ObjectAttribute("Field1", "Text") = "=Majors.FeesInUSD * Majors.CreditsRequired"

' Set the Totalizing property of Field1 to True
'.ObjectAttribute("Field1", "Totalizing") = True

'Compile the document and switch to Run mode
'this will fill the "Field1" object with the first record of the table
'each time this method is called, a new value is fetched from the table
.DoCommandTool (acCommandToolDesignMode)
.DoCommandTool (acCommandToolRunDocument)

'Save the pdf file
.Save "Test.pdf", 0

End With

Set pdf = Nothing

End Sub
Hope this helps.
Post Reply