使用jquery.print插件
庫爾勒網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)從2013年創(chuàng)立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
我用得jQuery.print, version 1.3.2。
頁面上調(diào)用代碼如下: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,然后雙擊PrintDocument1,在它的PrintPage事件中加入代碼如下:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
dim a as String
a="abcd"
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString(a, New Font("宋體", 20), New Pen(Color.Black, 1).Brush, 30, 30)
End Sub
調(diào)用下面語句可直接用默認(rèn)打印機(jī)打印出來:
PrintDocument1.Print()
比如:
Private Sub Document_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
e.Graphics.DrawString(str0, New Font("Arial", 14, FontStyle.Regular), Brushes.Black, 50, 50)
e.Graphics.DrawString(A1, New Font("Arial", 10, FontStyle.Regular), Brushes.Black,50, 100)
e.Graphics.DrawString(A2, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 300,100)
e.Graphics.DrawString(A3, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 800,100)
也就是分次用不同坐標(biāo)和不同的字體來打印各變量。畫線用:
e.Graphics.DrawLine(BlackPen, x1, y1, x2, y2)。
具體坐標(biāo)數(shù)值自己用尺量出,再換算。