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.

Tue Nov 09, 2021 4:03 am

Environment:
dotnet:3.1
Spire.Office.NETCore:6.8.2
Code:
Code: Select all
        [HttpPost]
        [Route("from-pdf")]
        public async Task<IActionResult> PrintFromPdf([FromForm] PrintFromTemplateRequest request)
        {
            Spire.Pdf.PdfDocument pdfdocument = new Spire.Pdf.PdfDocument();
            pdfdocument.LoadFromStream(request.PdfFile.OpenReadStream());
            pdfdocument.PrintSettings.PrinterName = request.PrinterName;
            pdfdocument.Print();
            pdfdocument.Dispose();
            return Ok();
       }

Description:
The printer I use is ZDesigner GK888t.
The label size is 75*50mm.
when i use Adobe Acrobat Pro DC2020.013.20074 print,it is normal.
print.png

20211108-edit.zip

raochenglong
 
Posts: 18
Joined: Mon Aug 23, 2021 5:11 pm

Tue Nov 09, 2021 8:34 am

Hello,

Thanks for your inquiry.
Sorry that we don't have the same printer as yours to fully test your case. I tested your PDF file with the printer "HP LaserJet P1007" and "HP Universal Printing PCL 6", but none of them could reproduce the issue. Could you please have a try with other printers? And I suggest you use the latest Spire. Office. NETCore 6.10.3 to test again. I am looking forward to your test result. If the issue still exists after testing, please provide your test environment (such as OS info (Eg Windows 7, 64-bit) and region setting (Eg China, Chinese))for our reference. Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Nov 09, 2021 9:18 am

Annika.Zhou wrote:Hello,

Thanks for your inquiry.
Sorry that we don't have the same printer as yours to fully test your case. I tested your PDF file with the printer "HP LaserJet P1007" and "HP Universal Printing PCL 6", but none of them could reproduce the issue. Could you please have a try with other printers? And I suggest you use the latest Spire. Office. NETCore 6.10.3 to test again. I am looking forward to your test result. If the issue still exists after testing, please provide your test environment (such as OS info (Eg Windows 7, 64-bit) and region setting (Eg China, Chinese))for our reference. Thanks in advance.

Sincerely,
Annika
E-iceblue support team

the same of 6.10.3
environment:
os:win10x64
region:China, Chinese

raochenglong
 
Posts: 18
Joined: Mon Aug 23, 2021 5:11 pm

Tue Nov 09, 2021 10:13 am

Hello,

Thank you for your feedback.
I tested your PDF file again on Windows 10, but still did not reproduce your issue. Since we do not have the type of printer you are using, please use XpsPrint (the attachment is the XpsPrintHelper package) to check whether the problem is related to ZDesigner GK888t printer. The test code is as follows:
Code: Select all
Spire.Pdf.PdfDocument pdfdocument = new Spire.Pdf.PdfDocument();
pdfdocument.LoadFromStream(request.PdfFile.OpenReadStream());
MemoryStream ms = new MemoryStream();
pdfdocument.SaveToStream(ms, FileFormat.XPS);
ms.Position = 0;
XpsPrint.XpsPrintHelper.Print(ms, request.PrinterName, "My printing job", true);

In addition, you could use the System.Drawing.Printing provided by .NET to do print with your printer and tell us your testing result. Please refer to the following code. I am looking forward to your feedback.
Code: Select all
        private void pdfPrint(string filePath)
        {
            PrintDocument pd = new PrintDocument();
            Process p = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo. CreateNoWindow = true;
            startInfo. WindowStyle = ProcessWindowStyle.Hidden;
            startInfo. UseShellExecute = true;
            startInfo. FileName = filePath;
            startInfo. Verb = "print";
            startInfo. Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\"";
            p.StartInfo = startInfo;
            p.Start();
            p.WaitForExit();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string filePath = "input.pdf";
            pdfPrint(filePath);
        }


Sincerely,
Annika
E-iceblue support team
User avatar

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

Return to Spire.PDF