|
|
Introduction
This is a small example designed to demonstrate
creating an Invoice with qPrinter². The routine demonstrates
some of the features of qPrinter² including Templates, the CreateColumns
method and Inline styles.
Dim vWidth(1 To 5) As
Variant
Dim sText As
String
Dim qPrint As
qcPrinter
' Initialise qPrint and set ScaleMode
Set qPrint = New
qcPrinter
qPrint.Document.ScaleMode = eMillimetre
' Add Template for general information:
qPrint.Document.AddTemplateBlock
"Verdana", 11, "styleBody"
' Title
qPrint.Document.AddFormatBlock
"COMPANY NAME INVOICE", "Arial", 12, True, , , , eCentre
' Address
sText = "Company Name" & vbCrLf &
"Street Address" & vbCrLf &
"Town/City" & vbCrLf & "Country"
qPrint.Document.AddFormatBlock sText, "Arial", 11, True, , , , eRight
' Customer Details - using 'styleBody'
Template
qPrint.Document.AddTextBlock
"<b>Customer Name:</b><tab=50>Blah Smith", "styleBody"
sText = "<b>Customer Address:</b><lindent=50>Street Address"
& vbCrLf _
&
"Town/City" & vbCrLf & "Zip Code"
& vbCrLf & "Country" & vbCrLf
qPrint.Document.AddTextBlock sText, "styleBody"
qPrint.Document.AddTextBlock
"<b>Customer Number:</b><tab=50>100001", "styleBody"
qPrint.Document.AddTextBlock
"<b>Order Number:</b><tab=50>100001", "styleBody"
' Create header row templates for the table
qPrint.Document.CreateColumns 5, "tbHead", True, "Arial", 11, eCentre, 0, 0, ccrFirstRow, 0, 2, 5, 1, 2, 2
' Create a template for Order Items to be
inserted in the Invoice
qPrint.Document.CreateColumns 5, "tbItem", True, "Arial", 11, eLeft, 0, 0, ccrMiddleRow, 0, 2, 5, 1, 2, 2
' Adjust the Order Item Templates:
' First Column (Item ID Number) - No changes
' Second Column (Item Description) - Make
italic:
qPrint.Document.Templates("tbItem2").FontItalic = True
' Third Column (Quantity) - Right Justify
Number
qPrint.Document.Templates("tbItem3").Alignment = eRight
' Fourth Column (Item Cost) - Right Justify
Number, Courier New font
qPrint.Document.Templates("tbItem4").Alignment = eRight
qPrint.Document.Templates("tbItem4").FontName =
"Courier New"
' Fifth Column (SubTotal) - Right Justify
Number, Courier New font, Bold text
qPrint.Document.Templates("tbItem5").Alignment = eRight
qPrint.Document.Templates("tbItem5").FontName =
"Courier New"
qPrint.Document.Templates("tbItem5").FontBold = True
' Insert the Header row for the start of the
Invoice
qPrint.Document.InsertRow "tbHead", "", False, "ID", "Description", "Qty", "Price", "Sub-Total"
' Add each item to the order
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
qPrint.Document.InsertRow "tbItem", "", False, "1001", "Sales Item Description", "1", "£ 2.40", "£ 2.40"
' Insert Total row using Bold text:
' The last two values (10,2) are the column
widths. The first value 10 means the left
' hand column will span 4 of the above
columns:
qPrint.Document.CreateColumns 2, "tbTotal", False, "Arial", 11, eLeft, 0, 0, ccrLastRow, 0, 10, 2
qPrint.Document.DocumentItems("tbTotal1").FontBold = True
qPrint.Document.DocumentItems("tbTotal1").Text =
"Total"
qPrint.Document.DocumentItems("tbTotal2").FontName =
"Courier New"
qPrint.Document.DocumentItems("tbTotal2").FontBold = True
qPrint.Document.DocumentItems("tbTotal2").Alignment =
eRight
qPrint.Document.DocumentItems("tbTotal2").Text =
"£14.40"
' Display a Preview of the Invoice
qPrint.Preview
' Clear the qPrint object
Set qPrint = Nothing
|