Search code examples
vb.netdevexpressxtrareport

Print a report without preview view and without preview browser view


How can I print a report without the preview, and taking the default local printer? I try to put this code lines, but does´nt work:

Dim rep As New XtraReport1()
rep.DataSource = DataSet
rep.CreateDocument()
rep.Print()

Thank you


Solution

  • I solve my problem with this code:

    Imports DevExpress.XtraReports.UI
    Imports System.IO
    Imports DevExpress.XtraPrinting
    Imports System.Data
    Imports System.Drawing
    
    Partial Class TPV_Tickets
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            Dim Report As New TicketTPV
    
           ' THIS IS TO TAKE THE DEFAULT LOCAL PRINT
            Dim instance As New Printing.PrinterSettings
            Dim DefaultPrinter As String = instance.PrinterName
    
            ' THIS IS TO PRINT THE REPORT
            Report.PrinterName = DefaultPrinter
            Report.CreateDocument()
            Report.PrintingSystem.ShowMarginsWarning = False
            Report.Print()
    
        End Sub
    End Class