重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
使用jquery.print插件
创新互联网站建设公司是一家服务多年做网站建设策划设计制作的公司,为广大用户提供了网站设计制作、做网站,成都网站设计,广告投放,成都做网站选创新互联,贴合企业需求,高性价比,满足客户不同层次的需求一站式服务欢迎致电。
我用得jQuery.print, version 1.3.2。
页面上调用代码如下:PrintArea就是你panel的ID....
script src="~/Scripts/jQuery.print.js"/script
script
function printarea() {
$("#PrintArea").print({
globalStyles: true,
mediaPrint: false,
stylesheet: null,
noPrintSelector: ".no-print",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred()
});
}
/script
a class="btn btn-success" onclick="printarea()"打印/a
PrintDocument1.Print()
使用PrintDocument进行打印“Brush, 50, 80”50左边距离,80上面距离
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString("取号单", New Font("Microsoft Sans Serif", 18, FontStyle.Bold), New Pen(Color.Black, 1).Brush, 30, 30)
e.Graphics.DrawString("XXXXXX", New Font("Microsoft Sans Serif", 24, FontStyle.Regular), New Pen(Color.Black, 1).Brush, 50, 80)
e.Graphics.DrawString("您的号码是:", New Font("Microsoft Sans Serif", 16, FontStyle.Regular), New Pen(Color.Black, 1).Brush, 30, 135)
e.Graphics.DrawString("打印时间:" Now(), New Font("Microsoft Sans Serif", 10, FontStyle.Regular), New Pen(Color.Black, 1).Brush, 80, 330)
End Sub
使用 PrintDocument 控件的 Print() 方法可以打印指定对象中的内容,参考代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(Me.DataGridView1.Width, Me.DataGridView1.Height)
DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
e.Graphics.DrawImage(bm, 0, 0)
End Sub