>How can I print on two different printers but with different conditions, for example, when a single copy is printed it is printed on printer "X" and if two copies are printed it is printed on printer "Y" in c#.
using (PrintDocument pd = new PrintDocument())
{
pd.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
pd.PrinterSettings.PrinterName = "Datamax";
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.DefaultPageSettings.PaperSize = new PaperSize("Custom", 403, 244);
pd.Print();
}
try
{
Conexion.Open();
System.Diagnostics.Debug.WriteLine("ComboBox" + guna2ComboBox1.SelectedItem);
SqlCommand cmd1 = new SqlCommand("XUltra", Conexion);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add("@Maquina", SqlDbType.NVarChar).Value = guna2ComboBox1.SelectedValue;
;
DataTable dtq = new DataTable();
dtq.Load(cmd1.ExecuteReader());
dataGridView3.DataSource = dtq;
}
catch (Exception ex)
{
throw new Exception("", ex);
}
Conexion.Close();
<pre> private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
copies--;
pageNum++;
var g = e.Graphics;
using (var fnt = new Font("Courier New", 14, FontStyle.Bold))
using (var f = new Font("Courier New", 8, FontStyle.Bold))
using (var fa = new Font("Courier New",11 , FontStyle.Bold))
{
g.DrawString("ATLTZAYANCA", fnt, Brushes.Black, 135, 10);
g.DrawString(guna2TextBox3.Text, fnt, Brushes.Black, 137, 65);
g.DrawString(guna2ComboBox1.Text,fnt,Brushes.Black, 178, 171);
g.DrawString($"Etiqueta {pageNum}", f, Brushes.Black, 215, 230);
g.DrawString($"Cantidad {label9.Text}", f, Brushes.Black, 165, 108);
g.DrawString($"Tensión {guna2TextBox4.Text}", f, Brushes.Black, 165, 125);
g.DrawString(guna2TextBox1.Text, fa, Brushes.Black, 135, 40);
g.DrawString(guna2TextBox2.Text, f, Brushes.Black, 135, 90);
e.HasMorePages = copies > 0;
}
}
This is my code, here I only use one printer and it does not have the condition that I would like it to have so that if two or more copies are printed, they are sent to another printer.
What I have tried:
I already investigated but nothing has come out that helps me with what I need.