Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Jun 24, 2021 4:38 pm

Hello,

I am trying to use spire to print a pdf document out onto a printer

I know that the printer exists and the printer name is correct and I know that the file exists and is correct but I am getting the error "The call to Member Print Failed: Settings to Access Printer are invalid.


this is the code I am using:

LTS_PDFDoc := LTS_PDFDoc.PdfDocument;
LTS_PDFDoc.LoadFromFile(PTS_FileName);
LTS_PDFDoc.PrinterName := PTS_PrinterName;
LTS_PDFDoc.PrintDocument.PrinterSettings.Copies := 1;
LTS_PDFDoc.PrintDocument.Print;

has anyone got any ideas please? I

Many Thanks

Lee

Leegeorge
 
Posts: 1
Joined: Thu Jun 24, 2021 3:11 pm

Fri Jun 25, 2021 9:47 am

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
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Jul 02, 2021 7:12 am

Hi,

Greetings from e-iceblue.
How is your issue going? Can you give us some feedback at your convenience? Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron