'[函数功能:][设定考生考试成绩的打印格式]
'[输入参数:][无]
'[输出参数:][无]
'[函数用法:][在打印时设计打印的格式]
'[完成时间:][2004-4-27]
'[函数作者:][LK]
'[应用范围:][本模块使用]
'[重要算法:]
'[函数注解:]
Private WithEvents printdoc As New Printing.PrintDocument
Private Sub printdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printdoc.PrintPage
Dim g As Graphics = e.Graphics
Dim pen As New Drawing.Pen(Color.Black, 3)
Dim strfont1 As String = "黑体" 'arial
Dim strfont2 As String = "宋体"
Dim font As New Font(strfont1, 16, FontStyle.Bold)
Dim font1 As New Font(strfont2, 12)
Dim font2 As New Font(strfont2, 12)
g = e.Graphics
'draw page title
g.DrawString("山东省营运汽车驾驶员从业资格", font, Brushes.Black, 250, 100)
g.DrawString("理论考试成绩单", font, Brushes.Black, 330, 140)
Dim ulCorner As New Point(560, 200) '[左上角]
Dim urCorner As New Point(650, 200) '[右上角]
Dim llCorner As New Point(560, 320) '[左下角]
Dim destPara As Point() = {ulCorner, urCorner, llCorner}
If File.Exists("c:\picwartmp\aa.jpg") Then
e.Graphics.DrawImage(Image.FromFile("c:\picwartmp\aa.jpg"), destPara)
End If
Application.DoEvents()
示例
[Visual Basic, C#, C++] 下面的示例使用打印机支持的纸张大小来填充 comboPaperSize 组合框。此外,将创建自定义的纸张大小并将其添加到组合框中。PaperName 被标识为一个属性,该属性将为通过组合框的 DisplayMember 属性添加的项提供显示字符串。该示例假定存在名为 printDoc 的 PrintDocument 变量,并且存在特定的组合框。
[Visual Basic]
' Add list of supported paper sizes found on the printer.
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName"
Dim pkSize As PaperSize
For i = 0 to printDoc.PrinterSettings.PaperSizes.Count - 1
pkSize = printDoc.PrinterSettings.PaperSizes.Item(i)
comboPaperSize.Items.Add(pkSize)
Next
' Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
Dim pkCustomSize1 As New PaperSize("Custom Paper Size", 100, 200)