Class MainWindow 
    Dim myp As VBprinter.VB2008Print = New VBprinter.VB2008Print()
    Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        AddHandler myp.HeaderFooterOut, AddressOf MyHeaderOut
    End Sub
    Private Sub MyHeaderOut(ByVal pages As System.Int32, ByVal curpage As System.Int32)
        myp.PrintFooter("中国航空动力机械研究所", "第" & CStr(curpage) & "页  共" & CStr(pages) & "页", "")
        myp.PrintHeader("打印时间：" & CStr(Now.ToString), "", "")
    End Sub
    Private Sub MainWindow_Unloaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Unloaded
        myp.Dispose()
        myp = Nothing
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        myp.IsImmediatePrintNotPreview = False
        myp.IsShowProgess = True
        MyPrint()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
        myp.IsImmediatePrintNotPreview = True
        myp.IsImmediatePrintNotPreviewShowPrintDialog = True
        myp.IsShowProgess = True
        MyPrint()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button3.Click
        myp.IsImmediatePrintNotPreview = True
        myp.IsShowProgess = False '不显示状态条
        myp.IsShowPrintStatusDialog = False '不显示打印状态
        myp.IsImmediatePrintNotPreviewShowPrintDialog = False
        MyPrint()
    End Sub
    Private Sub MyPrint()
        myp.NewDoc()
        myp.NewPage()
        Dim myfont As New System.Drawing.Font("宋体", 14)
        myp.DrawTitle("以普通方式打印文本", New System.Drawing.Font("黑体", 18, System.Drawing.FontStyle.Bold), System.Drawing.Color.Red)
        myp.DrawText(TextBox1.Text, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.DrawTitle("以单倍行距打印文本", New System.Drawing.Font("黑体", 18, System.Drawing.FontStyle.Bold), System.Drawing.Color.Red)
        myp.DrawTextEx(TextBox1.Text, myfont, System.Drawing.Brushes.Black, -1)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.DrawTitle("以0.5倍行距打印文本", New System.Drawing.Font("黑体", 18, System.Drawing.FontStyle.Bold), System.Drawing.Color.Red)
        myp.DrawTextEx(TextBox1.Text, myfont, System.Drawing.Brushes.Black, -0.5)
        '还可以写其他打印代码，就像在窗口程序中使用VB2008Print组件中一样
        myp.EndDoc("WPF中打印预览测试")
    End Sub
  

  
   
 
End Class
