欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

实例067打印图片

程序员文章站 2024-03-08 10:11:04
...

Graphics.DrawImage 方法

https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.graphics.drawimage?view=dotnet-plat-ext-3.1

控件 属性 控件 属性
Form Name Form1 Panel Name Panel1
PicturesBox Name picBox Button Name btnPrint
        Text 打印图片

 

实例067打印图片

Public Class Form1
    Private Sub print_PrintPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
        e.Graphics.DrawImage(picBox.Image, e.Graphics.VisibleClipBounds)
    End Sub

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        Dim pd As New Printing.PrintDocument
        AddHandler pd.PrintPage, AddressOf print_PrintPage
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        picBox.Image = Image.FromFile("C:\Users\Administrator\Pictures\1.jpg")
    End Sub
End Class