Hello,
Thanks for your inquiry.
I used the latest version of Spire.PDF (
Spire.PDF Pack Version: 7.6) to test printing using the C# code, but I did not encounter your issue. Below is my testing code. According to the error details you mentioned, I guess this issue may be caused by the access permission of your printer. I would suggest that you give the latest version a try and you could try other printer, such as the virtual printer (Microsoft XPS Document Writer), then tell us your result.
- Code: Select all
string inputFile = "PrintPDF";
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile );
pdf.PrinterName = "PrinterName";
pdf.PrintSettings.Copies = 1;
pdf.Print();
And please also use the following code to check if there is any problem to do print.
- Code: Select all
static void Main(string[] args)
{
PrintDocument printDocument1 = new PrintDocument();
var printerSettings = new PrinterSettings();
printerSettings.PrinterName = "PrinterName";
printerSettings.Copies = 1;
printDocument1.PrinterSettings = printerSettings;
printDocument1.PrintPage += PrintDocument1_PrintPage;
printDocument1.Print();
}
public static void PrintDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("Test print", new Font("Arial", 10), Brushes.Black, 100, 20);
e.Graphics.PageUnit = GraphicsUnit.Inch;
}
Look forward to your reply. Thanks in advance.
Sincerely,
Annika
E-iceblue support team