你現在的默認打印機是Adobe PDF,修改一下默認打印機為你現在需要的打印機即可。

創新互聯建站堅持“要么做到,要么別承諾”的工作理念,服務領域包括:成都網站制作、成都網站設計、企業官網、英文網站、手機端網站、網站推廣等服務,滿足客戶于互聯網時代的扎賚特網站設計、移動媒體設計的需求,幫助企業找到有效的互聯網解決方案。努力成為您成熟可靠的網絡建設合作伙伴!
利用DataWindow.net在 vb.net 下導出PDF格式文件
利用datawindow.net,導出PDF文件,實現前提:
1.安裝Acrobat Distiller虛擬打印機,注意要用datawindow.net提供的打印驅動,在c:\program files\sybase\datawindow.net2.0\driver中,在文章最后,我會提供一個靜態安裝虛擬打印機的批處理文件,方便安裝。
2.安裝Ghostscript 7.05 ,在網上找,免費的。
3.導出PDF文件前,一要指定虛擬打印機名,其次導出格式為PDF(Export.PDF.Method=Distill!),另外還要指定 PDF.Distill.CustomPostScript=Yes。
具體代碼如下:
''' summary
''' 導出文件
''' /summary
''' param name="sender"/param
''' param name="e"/param
''' remarks/remarks
Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
Try
Dim strFilename, strPrinter As String
Dim saveDg As New SaveFileDialog
strPrinter = Me.dwPrint.Describe("DataWindow.Print.PrinterName")
saveDg.FileName = Me.dwPrint.Tag.ToString
saveDg.Filter = "Pdf文件|*.pdf|Excel文件|*.xls|所有文件|*.*"
If saveDg.ShowDialog = Windows.Forms.DialogResult.OK Then
strFilename = saveDg.FileName
If strFilename.IndexOf(".pdf") 0 Then
Me.dwPrint.Modify("DataWindow.Print.PrinterName='Acrobat Distiller'")
Me.dwPrint.Modify("DataWindow.Export.PDF.Method=Distill!")
Me.dwPrint.Modify("DataWindow.Export.PDF.Distill.CustomPostScript=Yes")
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Pdf, True)
ElseIf strFilename.IndexOf(".xls") 0 Then
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Excel, True)
End If
Me.dwPrint.Modify("DataWindow.Print.PrinterName='" + strPrinter + "'")
MessageBox.Show("導出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
4 批處理文件(實現靜默安裝)
Public?Class?Print
'建立一個button控件,click事件
Private?Sub?Button1_Click(sender?As?Object,?e?As?EventArgs)?Handles?Button1.Click
PrintDocument1.Print()??'打印PrintDocument1控件
End?Sub
Private?Sub?PrintDocument1_PrintPage(sender?As?Object,?e?As?Printing.PrintPageEventArgs)?Handles?PrintDocument1.PrintPage
Dim?stringFont?As?New?Font("Arial",?16)??'字體?字號
Dim?rectDraw?As?New?RectangleF(e.MarginBounds.Left,?e.MarginBounds.Top,?e.MarginBounds.Width,?e.MarginBounds.Height)
Dim?strFormat?As?New?StringFormat
Dim?s?As?String
s?=?"print?word"?'打印的內容
e.Graphics.DrawString(s,?stringFont,?Brushes.Black,?rectDraw,?strFormat)
End?Sub
End?Sub
End?Class
文章標題:vb.netpdf打印 vbnet printdocument
文章源于:http://www.yijiale78.com/article26/ddocgcg.html
成都網站建設公司_創新互聯,為您提供營銷型網站建設、網站排名、服務器托管、做網站、、響應式網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯