Hello,
Does anybody have a sample of PDFCreator in VB6 ?
(ie. Create PDF from scratch, inserting text with different size, fonts, inserting images...)
TIA,
PDFCreator sample in VB6
Hello,
Please find here a sample VB6 code to create a new pdf file from scratch and add some objects to it.
Hope this helps
=============================================
Option Explicit
Dim pdf As New ACPDFCREACTIVEX.PDFCreactiveX
Const Licensee As String = "Amyuni Technologies"
Const ActivationCode As String = "07EFCDAB010001..."
Private Sub Command5_Click()
With pdf
.SetLicenseKey Licensee, ActivationCode
'Create a text object
.CreateObject acObjectTypeText, "text1"
'Position the text
.ObjectAttribute("text1", "Left") = 200
.ObjectAttribute("text1", "Top") = 200
.ObjectAttribute("text1", "Right") = .PageWidth
.ObjectAttribute("text1", "Bottom") = 400
'Set the Text, TextFont and HorzAlign attributes of text1
.ObjectAttribute("text1", "Text") = "This is a sample application"
.ObjectAttribute("text1", "TextFont") = "Verdana,12,1,1"
.ObjectAttribute("text1", "HorzAlign") = 3
' Refresh the object when all its properties are defined
.RedrawObject ("text1")
'Create a Line object
.CreateObject acObjectTypeLine, "line1"
'Set the attributes of the line
.ObjectAttribute("line1", "left") = 200
.ObjectAttribute("line1", "Top") = 600
.ObjectAttribute("line1", "Right") = 8000
.ObjectAttribute("line1", "Bottom") = 600
'Create a second Text object
.CreateObject acObjectTypeText, "text2"
'Set the attributes of the second text
.ObjectAttribute("text2", "Left") = 200
.ObjectAttribute("text2", "Top") = 1500
.ObjectAttribute("text2", "Right") = 600
.ObjectAttribute("text2", "Bottom") = 1700
.ObjectAttribute("text2", "Text") = " Page 1 : Picture (centered) "
.ObjectAttribute("text2", "HorzAlign") = 2
.RedrawObject ("text2")
'Create a picture object
.CreateObject acObjectTypePicture, "picture1"
'Set the picture attributes
.ObjectAttribute("picture1", "Left") = 600
.ObjectAttribute("picture1", "Top") = 3000
.ObjectAttribute("picture1", "Right") = 4000
.ObjectAttribute("picture1", "Bottom") = 8000
.ObjectAttribute("picture1", "FileName") = "picture.jpg"
.ObjectAttribute("picture1", "BorderWidth") = 2
' Add a second page to the pdf document
.AddPage (2)
'Create a Third Text object
.CreateObject acObjectTypeText, "text3"
'Set the attributes of the third text
.ObjectAttribute("text3", "Left") = 200
.ObjectAttribute("text3", "Top") = 3000
.ObjectAttribute("text3", "Right") = 2300
.ObjectAttribute("text3", "Bottom") = 3400
.ObjectAttribute("text3", "Text") = " Page 2 : Excel File "
.ObjectAttribute("text3", "BorderWidth") = 2
' Create a rectangle frame object
.CreateObject acObjectTypeFrame, "frame"
'Set the attributes of this frame
.ObjectAttribute("frame", "Left") = 4200
.ObjectAttribute("frame", "Top") = 14300
.ObjectAttribute("frame", "Right") = 7300
.ObjectAttribute("frame", "Bottom") = 15000
.ObjectAttribute("frame", "text") = "Amyuni Technologies: www.amyuni.com"
'Set it as a hyperlink
.ObjectAttribute("frame", "Hyperlink") = "www.amyuni.com"
'Set Bookmarks to the PDF file.
' Create new Bookmarks
Dim root As acBookmark
Dim child As acBookmark
' Set these Bookmarks
Set root = pdf.RootBookmark
'insert root bookmark at top level
root.InsertChild 0, "Pages", "text1", child
'insert two child bookmarks
child.InsertChild 0, "Page 2", "text4", Nothing
child.InsertChild 0, "Page 1", "text2", Nothing
'Delete the bookmarks objects
Set child = Nothing
Set root = Nothing
'Save the pdf file
.Save "Test11.pdf", 0
End With
End Sub
=============================================
Please find here a sample VB6 code to create a new pdf file from scratch and add some objects to it.
Hope this helps
=============================================
Option Explicit
Dim pdf As New ACPDFCREACTIVEX.PDFCreactiveX
Const Licensee As String = "Amyuni Technologies"
Const ActivationCode As String = "07EFCDAB010001..."
Private Sub Command5_Click()
With pdf
.SetLicenseKey Licensee, ActivationCode
'Create a text object
.CreateObject acObjectTypeText, "text1"
'Position the text
.ObjectAttribute("text1", "Left") = 200
.ObjectAttribute("text1", "Top") = 200
.ObjectAttribute("text1", "Right") = .PageWidth
.ObjectAttribute("text1", "Bottom") = 400
'Set the Text, TextFont and HorzAlign attributes of text1
.ObjectAttribute("text1", "Text") = "This is a sample application"
.ObjectAttribute("text1", "TextFont") = "Verdana,12,1,1"
.ObjectAttribute("text1", "HorzAlign") = 3
' Refresh the object when all its properties are defined
.RedrawObject ("text1")
'Create a Line object
.CreateObject acObjectTypeLine, "line1"
'Set the attributes of the line
.ObjectAttribute("line1", "left") = 200
.ObjectAttribute("line1", "Top") = 600
.ObjectAttribute("line1", "Right") = 8000
.ObjectAttribute("line1", "Bottom") = 600
'Create a second Text object
.CreateObject acObjectTypeText, "text2"
'Set the attributes of the second text
.ObjectAttribute("text2", "Left") = 200
.ObjectAttribute("text2", "Top") = 1500
.ObjectAttribute("text2", "Right") = 600
.ObjectAttribute("text2", "Bottom") = 1700
.ObjectAttribute("text2", "Text") = " Page 1 : Picture (centered) "
.ObjectAttribute("text2", "HorzAlign") = 2
.RedrawObject ("text2")
'Create a picture object
.CreateObject acObjectTypePicture, "picture1"
'Set the picture attributes
.ObjectAttribute("picture1", "Left") = 600
.ObjectAttribute("picture1", "Top") = 3000
.ObjectAttribute("picture1", "Right") = 4000
.ObjectAttribute("picture1", "Bottom") = 8000
.ObjectAttribute("picture1", "FileName") = "picture.jpg"
.ObjectAttribute("picture1", "BorderWidth") = 2
' Add a second page to the pdf document
.AddPage (2)
'Create a Third Text object
.CreateObject acObjectTypeText, "text3"
'Set the attributes of the third text
.ObjectAttribute("text3", "Left") = 200
.ObjectAttribute("text3", "Top") = 3000
.ObjectAttribute("text3", "Right") = 2300
.ObjectAttribute("text3", "Bottom") = 3400
.ObjectAttribute("text3", "Text") = " Page 2 : Excel File "
.ObjectAttribute("text3", "BorderWidth") = 2
' Create a rectangle frame object
.CreateObject acObjectTypeFrame, "frame"
'Set the attributes of this frame
.ObjectAttribute("frame", "Left") = 4200
.ObjectAttribute("frame", "Top") = 14300
.ObjectAttribute("frame", "Right") = 7300
.ObjectAttribute("frame", "Bottom") = 15000
.ObjectAttribute("frame", "text") = "Amyuni Technologies: www.amyuni.com"
'Set it as a hyperlink
.ObjectAttribute("frame", "Hyperlink") = "www.amyuni.com"
'Set Bookmarks to the PDF file.
' Create new Bookmarks
Dim root As acBookmark
Dim child As acBookmark
' Set these Bookmarks
Set root = pdf.RootBookmark
'insert root bookmark at top level
root.InsertChild 0, "Pages", "text1", child
'insert two child bookmarks
child.InsertChild 0, "Page 2", "text4", Nothing
child.InsertChild 0, "Page 1", "text2", Nothing
'Delete the bookmarks objects
Set child = Nothing
Set root = Nothing
'Save the pdf file
.Save "Test11.pdf", 0
End With
End Sub
=============================================