-1

We have software like doPdf which prints without necessarily giving hard copy output. can somebody send me a code that can print a crystal report with a printer without giving physical output which will enable me save the file with a given name before sending it via E-mail.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

Maybe this will help:

Imports System.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Namespace WindowsApplication1
	Public Partial Class Form1
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub button1_Click(sender As Object, e As EventArgs)
			Dim cryRpt As New ReportDocument()
			cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")

			Dim crtableLogoninfos As New TableLogOnInfos()
			Dim crtableLogoninfo As New TableLogOnInfo()
			Dim crConnectionInfo As New ConnectionInfo()
			Dim CrTables As Tables

			crConnectionInfo.ServerName = "YOUR SERVERNAME"
			crConnectionInfo.DatabaseName = "DATABASE NAME"
			crConnectionInfo.UserID = "USERID"
			crConnectionInfo.Password = "PASSWORD"

			CrTables = cryRpt.Database.Tables
			For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
				crtableLogoninfo = CrTable.LogOnInfo
				crtableLogoninfo.ConnectionInfo = crConnectionInfo
				CrTable.ApplyLogOnInfo(crtableLogoninfo)
			Next

			cryRpt.Refresh()
			cryRpt.PrintToPrinter(1, True, 0, 0)

		End Sub
	End Class
End Namespace
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.