Click here to Skip to main content
14,489,815 members
Rate this:
Please Sign up or sign in to vote.
See more:
I sending direct print on printer without open any print document or any adds (just like POS) i have applied this

What I have tried:

Dim ConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim CashReceipt As New ReportDocument()
CashReceipt.Load(Application.StartupPath & "\Reports\Sale Reports\CashReceipt.rpt")
Dim MyTables As Tables = CashReceipt.Database.Tables

For Each MyTable As CrystalDecisions.CrystalReports.Engine.Table In MyTables
   Dim MyTableLogonInfo As TableLogOnInfo = MyTable.LogOnInfo
   ConnectionInfo.ServerName = ".\SQLEXPRESS"
   ConnectionInfo.DatabaseName = ""Admin
   ConnectionInfo.UserID = "sa"
   ConnectionInfo.Password = "admin"
   ConnectionInfo.IntegratedSecurity = False
   MyTableLogonInfo.ConnectionInfo = ConnectionInfo
   MyTable.ApplyLogOnInfo(MyTableLogonInfo)
Next

RPTfrmCashReport.CrystalReportViewer1.ReportSource = CashReceipt

Dim mySelectionFormula As String = "{Invoice_Master.Invoice_no} = '" & FrmSalebill.LblInvoiceno.Text & "'"

CashReceipt.RecordSelectionFormula = mySelectionFormula
CashReceipt.PrintToPrinter(1, False, 0, 0)
Posted
Updated 5-Jan-20 6:53am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

In order to use something else than the default printer, you need to use ReportDocument.PrintOptions property[^]

Have a look at the PrintOptions Members (CrystalDecisions.CrystalReports.Engine) | Microsoft Docs[^]. There you'll find PrintOptions.PrinterName Property[^]. You can use that to set the desired printer and before printing set the print options to the report document.

For a small implementation, have a look at Choosing a printer when printing from Crystal Reports in C#[^]
   
Comments
Computechsoft 6-Jan-20 1:29am
   
I have applied this but same situation "OneNote is opening not direct print"


Dim mySelectionFormula As String = "{Invoice_Master.Invoice_no} = '" & FrmSalebill.LblInvoiceno.Text & "'"

CashReceipt.RecordSelectionFormula = mySelectionFormula

Dim printDocument = New Printing.PrintDocument
CashReceipt.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName
CashReceipt.PrintToPrinter(1, True, 1, 1)
Wendelius 6-Jan-20 2:43am
   
Since you don't change the printer name in the PrintDocument object, you get the same default printer.

To get started, try just to set the correct printer name to your print options. Something like
CashReceipt.PrintOptions.PrinterName = "MyDesiredPrinterName"


If needed, you can list the installed printers using PrinterSettings.InstalledPrinters Property (System.Drawing.Printing) | Microsoft Docs[^]
Computechsoft 6-Jan-20 3:35am
   
I am saying i don't want to open these documants
(Microsoft Print to pdf)
(Microsoft XPS Document writer)
(OneNote)

Receipt directly print on printer, before printing not open receipt in these Documents?
Wendelius 6-Jan-20 4:40am
   
I don't understand why you would open the document. If you set the printer to the printer name you want to use, the receipt is going to be printed on that printer. Based on the codes you have provided you always use the default printer, and if the default printer is OneNote, then the document will be printed using that.

As said, change the printer name to the one you want to use and try printing after that.

If you don't yet have the printer installed on your computer, connect to the printer first and then use the correct printer name. For information about adding a printer, see https://support.microsoft.com/en-us/help/4015386/windows-10-install-printer[^]
Computechsoft 6-Jan-20 5:51am
   
Thanks a lots issue is resolve. I can write English but not very well i hope you can understand better.
You are genius person, you are resolve this issue very technically.
Lastly I would like to wish you all a very successful future.

Best regards.
Wendelius 6-Jan-20 9:19am
   
You're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100