4
Yes, you can print the same document to two printers simultaneously using C#. To achieve this, you’ll need to print the document to both printers using their respective print queues. Here’s a step-by-step guide on how you might accomplish this:
-
Set Up the Print Document: First, create a PrintDocument
object in C# that represents the document you want to print.
-
Define the Print Jobs: Create two separate PrintDocument
objects or configure the same PrintDocument
object to use different PrintQueue
objects.
-
Print to Multiple Printers: Print the document to both printers by invoking the Print
method on each PrintDocument
object.
Here's a sample code snippet to illustrate how you might implement this:
using System;
using System.Drawing.Printing;
using System.Windows.Forms;
public class PrintHelper
{
public void PrintToMultiplePrinters(string printerName1, string printerName2)
{
// Create the PrintDocument object
PrintDocument printDoc = new PrintDocument();
// Set the PrintDocument's PrintPage event handler
printDoc.PrintPage += new PrintPageEventHandler(PrintPageHandler);
// Set up the printers
PrinterSettings printerSettings1 = new PrinterSettings { PrinterName = printerName1 };
PrinterSettings printerSettings2 = new PrinterSettings { PrinterName = printerName2 };
// Print to the first printer
printDoc.PrinterSettings = printerSettings1;
printDoc.Print();
// Print to the second printer
printDoc.PrinterSettings = printerSettings2;
printDoc.Print();
}
private void PrintPageHandler(object sender, PrintPageEventArgs e)
{
// Here you would add code to draw the content you want to print
e.Graphics.DrawString("Hello, world!", new Font("Arial", 12), Brushes.Black, new PointF(100, 100));
}
}

Accepted 1
Thank You so much for your answer
I'm getting the Print Job properties witch Win32_PrintJob
Then I use the ID value in the class SystemPrintInfoJob to ask for JobStream , but the value is always null
I wanna use that value to but later use send to Print
You know why that happens
Why that value is always null ??
Thank you