Hi
I have 1 Layout & printing it 3 times. I want on first print it should print Original & on second print 'Duplicate' & on third print 'Triplicate'
Thanks
Hi
I have 1 Layout & printing it 3 times. I want on first print it should print Original & on second print 'Duplicate' & on third print 'Triplicate'
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Dec 3, 2023, 11:28 AM EST
To achieve the desired result of printing multiple copies of an invoice with different labels using Crystal Report in C#, you can follow these steps:
Create a Crystal Report layout for the invoice with the necessary fields and design elements.
In your C# code, create an instance of the Crystal Report document and load the report layout.
Set the number of copies to be printed using the
PrintToPrintermethod of the Crystal Report document. This method allows you to specify the number of copies to be printed.To add the labels "Original," "Duplicate," and "Triplicate" to each copy, you can use the
ReportDocument.PrintOptionsproperty. This property provides access to various print options, including the printer name, number of copies, and collation.Use the
ReportDocument.PrintOptions.PrinterNameproperty to set the printer name to which the report should be sent.Use the
ReportDocument.PrintOptions.Copiesproperty to set the number of copies to be printed.Use the
ReportDocument.PrintOptions.Collatedproperty to specify whether the copies should be collated or not.Finally, call the
PrintToPrintermethod of the Crystal Report document to print the invoice with the specified number of copies and labels.Here's an example code snippet that demonstrates how to achieve this:
using CrystalDecisions.CrystalReports.Engine; // Create an instance of the Crystal Report document ReportDocument reportDocument = new ReportDocument(); // Load the report layout reportDocument.Load("InvoiceReport.rpt"); // Set the printer name reportDocument.PrintOptions.PrinterName = "Your Printer Name"; // Set the number of copies reportDocument.PrintOptions.Copies = 3; // Set the collation reportDocument.PrintOptions.Collated = true; // Print the report with the specified number of copies reportDocument.PrintToPrinter(1, false, 0, 0);Make sure to replace "InvoiceReport.rpt" with the actual path and filename of your Crystal Report layout file, and "Your Printer Name" with the name of your printer.
Amit MohantyRank #112 · 20K reputationPosted Dec 4, 2023, 4:12 AM EST
Check the below code, this may help you to resolve your issue.
private void btnPrint_Click(object sender, EventArgs e) { // Assuming parameterValue is the variable storing the user-selected parameter value (Original/Duplicate/Triplicate/ALL) string parameterValue = "your-parameter-value"; switch (parameterValue) { case "Original": PrintReport("Original"); break; case "Duplicate": PrintReport("Duplicate"); break; case "Triplicate": PrintReport("Triplicate"); break; case "All": PrintReport("Original"); PrintReport("Duplicate"); PrintReport("Triplicate"); break; default: // Handle any other cases or errors break; } } private void PrintReport(string selectedOption) { ConnectionInfo connectionInfo = new ConnectionInfo { ServerName = @"Your-Server-Name", DatabaseName = "SampleDB", UserID = "sa", Password = "pa$$w0rd" }; ReportDocument reportDocument = new ReportDocument(); reportDocument.Load("path_to_your_report_file.rpt"); reportDocument.SetParameterValue("SelectedOption", selectedOption); TableLogOnInfo tableLogOnInfo = new TableLogOnInfo(); Tables crTables = _reportDocument.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables) { tableLogOnInfo = crTable.LogOnInfo; tableLogOnInfo.ConnectionInfo = connectionInfo; crTable.ApplyLogOnInfo(tableLogOnInfo); } reportDocument.Refresh(); reportDocument.PrintToPrinter(1, false, 0, 0); }