Sharp use of PDF in VB6

Sharp use of PDF in VB6

Sharp use of PDF in VB6

Most individuals are in search of find out how to create PDF paperwork with their VB functions, however do not wish to spend cash to purchase the Adobe Acrobat SDK or different third-party elements. When you do not wish to make investments cash, there may be an open supply answer for you: SharpPDF. SharpPDF is a C# library based mostly on the .NET Framework 1.1 and produces a 100% appropriate PDF doc. Extra details about the SharpPDF library could be discovered at sharppdf.sourceforge.internet.

Visible Primary builders can’t use this library immediately. When you register SharpPDF and attempt to create the pdfDocument methodology, you’re going to get an error. So how will you use sharpPDF? An possibility I can consider is to vary the sharpPDF code based mostly in your wants. When you do not wish to mess with the sharpPDF code, you’ll be able to merely create a wrapper library in VB.NET, register the meeting, and reference the wrapper by means of your VB6 challenge.

To register a gathering, use the next command:
regasm /tlb: mywrapper.tlb /codebase mywrapper.dll

and add a reference to mywrapper.tlb out of your VB6 challenge

Instance of wrapper code created utilizing VB.NET:

Imports sharpPDF

Public class clsSharpPDFWrapper

Non-public m_sTitle As String

Non-public m_sAuthor As String

Non-public m_sContent As String

Public WriteOnly Property Title() As String

Set (ByVal worth As String)

m_sTitle = Worth

Final assortment

Finish property

Public WriteOnly Property Writer() As String

Set (ByVal worth As String)

m_sAuthor = Worth

Final assortment

Finish property

Public WriteOnly Property Content material() As String

Set (ByVal worth As String)

m_sContent = Worth

Final assortment

Finish property

public operate CreatePDFDocument()

Blur 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

The tip operate

Finish class

Instance code for calling a wrapper by means of your VB6 challenge:

Dim o As New clsSharpPDFWrapper

o.Title = “My First PDF Doc”

o.Writer = “Thomas Kaloani”

o.Content material = “Hiya World”.

o.createPDFDocument

Pleased coding!

#Sharp #PDF #VB6

Leave a Comment

Your email address will not be published.

Scroll to Top