VB2PDF

back to Home Page



Name

VB2PDF.cls

Version

 1.2

Author

Marco Nicolato (mnicolato@hotmail.com)

WEB Site

http://freeweb.lombardiacom.it/mnicolato

License type

email-ware (send me an e-mail if you use it !)

Description

VB2PDF is a simplex, pure VB driver to create a PDF file,
without any library, OCX or DLL.

Download

Download here the source



HISTORY

2000/10/24

First release 1.0

2002/02/21

Release 1.1: fixed the use with Acrobat 5
(generates always blank pages)

2003/05/30

Release 1.2: added positioning & text rotation



PROPERTIES

FileName

File name with full path and extension (usually .PDF)

Title
Subject
Author
Producer

If you fill these info, them will be showed in the document property of Acrobat Reader

PaperSize

The paper size, you can use one of these symbolic constants:
 pdfA3
 pdfA4
 pdfA5
 pdfTABLOID
 pdfLEDGER
 pdfLEGAL
 pdfSTATEMENT
 pdfEXECUTIVE
The default is pdfA4

LandScape

True or False: if TRUE, the page layout will be rotated by 90°
the default is FALSE

TopMargin

Margin from the top of the page
the default is 50

LeftMargin

Margin from the left of the page
the default is 50

FontSize

Font size
the default is 12

FontType

Font aspect: you can use one of these symbolic constants:
 pdfRegular;
 pdfBold;
 pdfItalic;
 pdfBoldItalic
the default is pdfRegular
Remark: the font shape is always COURIER

VertSpace

The spacing between the rows
the default is 10



METHODS

StartPDF()

Create the file and initialize all objects

WritePDF(
text as string,
newline as boolean,
[fonttype] as FontType)

Write <text> in the PDF file, and if <newline> is TRUE the text will start on a new line; optionally with <fonttype> you can select the aspect of the text (bold, italic, bolditalic or regular)

SetOrigin(
nStartX as Long,
nStartY as Long,
[nDegree] as Long)

Set text origin at <nStartX>, <nStartY> coordinates, and text <nDegree> rotation (optional, 0 default)
(nDegree: specify 0 for east direction, 90 for north, 180 for west and 270 for south)

NewPage()

Start a new page

EndPDF()

Close the document and all the objects: the .PDF is ready to be distributed





Example:

Dim myPDF As New VB2PDF
myPDF.PaperSize = pdfA4
myPDF.FileName = "c:\temp\test.pdf"
myPDF.StartPDF
myPDF.WritePDF "Hello world !", True
myPDF.WritePDF "This is a new row ", True
myPDF.WritePDF "and I can write in BOLD ", False, pdfBold
myPDF.WritePDF "or ITALIC ", False, pdfItalic
myPDF.WritePDF "or BOTH !", False, pdfBoldItalic
myPDF.WritePDF "And so and so ...", True
' Text Rotation sample
Dim i As Long
For i = 0 To 345 Step 15
    myPDF.SetOrigin 300, 500, i
    myPDF.WritePDF "--- NEW - text rotated by " & i & "°", False, pdfRegular
Next
myPDF.NewPage
myPDF.WritePDF "This is another page !", True
myPDF.EndPDF



Useful link:

- The PDF Reference Manual Version 1.3 (about 5 MB)

http://partners.adobe.com/asn/developer/PDFS/TN/PDFSPEC.PDF