Sharp PDF Usage in VB6

April 28th, 2008

Most grouping are hunting on how to create PDF documents finished their VB applications, but don’t poverty to pay money to acquire Adobe Acrobat SDK or another ordinal band components. If you don’t poverty to equip money, there is an unstoppered maker resolution for you, SharpPDF. SharpPDF is a rattling modify C# accumulation supported on .NET Framework 1.1 and created 100% harmonious PDF document. solon aggregation most SharpPDF accumulation crapper be institute on sharppdf.sourceforge.net.

Visual Basic developers can’t ingest this accumulation straight. If you run the SharpPDF and essay to create the pdfDocument method you’ll intend an error. So how crapper you verify plus of sharpPDF? A pick I crapper conceive of is to modify the cipher of sharpPDF supported on your needs. If you don’t poverty to disorderliness up with the cipher of sharpPDF you crapper only create a cloak accumulation with VB.NET, run the gathering and meaning the cloak finished you VB6 project.

To run the gathering ingest the mass command:
regasm /tlb: mywrapper.tlb /codebase mywrapper.dll

and from your VB6 send add a refence to mywrapper.tlb

Sample Code of cloak created with VB.NET:

Imports sharpPDF

Public Class clsSharpPDFWrapper
Private m_sTitle As String
Private m_sAuthor As String
Private m_sContent As String

Public WriteOnly Property Title() As String
Set(ByVal Value As String)
m_sTitle = Value
End Set
End Property

Public WriteOnly Property Author() As String
Set(ByVal Value As String)
m_sAuthor = Value
End Set
End Property

Public WriteOnly Property Content() As String
Set(ByVal Value As String)
m_sContent = Value
End Set
End Property

Public Function CreatePDFDocument()
Dim oPDF As New sharpPDF.pdfDocument(m_sTitle, m_sAuthor)
Dim oPDFPage As sharpPDF.pdfPage =
oPDF.addPage(sharpPDF.Enumerators.predefinedPageSize.csA4Page)

oPDFPage.addText(m_sContent, 200, 450,
oPDF.getFontReference(Enumerators.predefinedFont.csHelvetica), 20,
pdfColor.Black)

oPDF.createPDF(”c:MyPDFDoc.pdf”)
oPDFPage = Nothing
oPDF = Nothing
End Function
End Class

Sample Code for occupation the cloak finished your VB6 project:

Dim o As New clsSharpPDFWrapper
o.Title = “My First PDF Document”
o.Author = “Thomas Kaloyani”
o.Content = “Hello World!”
o.createPDFDocument

Happy coding!

Thomas is an old Visual Basic developer, with skillfulness of 7+ eld nonindustrial especially business applications. His important IT skills are VB, SQL, Crystal Reports - should you requirement a Visual Basic developer for your projects see liberated to occurrence saint finished his individualized website Kaloyani.com or finished VBprofs.com - the newest Visual Basic and VB.NET resources portal.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , ,
Close
E-mail It