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.

Fri Feb 12, 2021 6:12 pm

See the attached file. From Adobe Acrobat, it prints perfectly. DevExpress PdfDocumentProcessor also prints it correctly.

From SpirePDF, it prints as if it's ignoring the top margin, like the top of the document is aligned with the top edge of the paper. The result is about 1/8" of the document is cut off. I've tried adjusting margins and other settings, with no success. The printer is a Brother MFC-9450CDN, in case it matters.

This is the SpirePDF code used to print:

var pdf = new Spire.Pdf.PdfDocument();
pdf.LoadFromFile(pdfFile);
pdf.PrintSettings.PrinterName = printer;
pdf.PrintSettings.SelectSinglePageLayout(Spire.Pdf.Print.PdfSinglePageScalingMode.ActualSize);
pdf.PrintSettings.PrintController = new System.Drawing.Printing.StandardPrintController();
pdf.Print();

What do I need to do to get the document printed correctly?

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Mon Feb 15, 2021 5:38 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.

Sorry we do not have the MFC-9450CDN printer to verify the issue. But I made a test with the “Microsoft XPS Document Writer” printer but did not reproduce your issue. Please print with the XPS printer to verify this issue again on your side. Besides, please try the pdf.PrintSettings.SelectSinglePageLayout(Spire.Pdf.Print.PdfSinglePageScalingMode.FitSze) method to fit size when printing.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Feb 15, 2021 10:07 pm

Marcia,

Thanks for getting back to me.

We have now duplicated the problem on a number of printers. To summarize:
- Adobe Acrobat and DevExpress both print the document correctly on all printers.
- Spire prints the document incorrectly on all printers.

I have printed to "Microsoft Print to PDF". When the resulting file is opened in Acrobat, the document is correct. The problem appears to be in how Spire renders the document for physical printing.

I have already tried PdfSinglePageScalingMode.FitSize, as well as other options. The result using FitSize is unacceptable, as it shrinks the entire document, which results in certain text being moved from its required position. Specifically, the account number at the bottom of the document must be a certain distance from the bottom for machine reading. Another problem is that the text will no longer align properly with the detachable coupon on the production forms.

I've created a small test app that will demonstrate the problem. Your system will neither allow me to upload it, nor provide a URL to download it. Change the $ signs to forward slashes and you should be able to download from here:

http:$$qodex.ddns.us$download$SpireTest.zip

This is a C# .NET 4.7.2 console app created in Visual Studio. You can load it into Visual Studio and run it from there, or run SpireTest.exe from a Command Prompt. The app requires two parameters, and accepts an optional third:

// Usage: SpireTest.exe <printer> <pdf filename> [processor]
// processor = spire or dx, default spire

Example:

SpireTest.exe "Brother MFC-9450CDN Printer" ..\..\TestDoc.pdf dx

This will use DevExpress to render the document then send it to the Brother printer.

"Brother MFC-9450CDN Printer" ..\..\TestDoc.pdf

This will use SpirePDF to render the document then send it to the Brother printer.

Please try both DevExpress and SpirePDF on a physical printer and compare the output. You can also try printing from Adobe Acrobat. Please let me know what you find.

Thanks!

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Tue Feb 16, 2021 10:54 am

Hello,

Thank you for sharing more information.
Since we have a 7-Day Chinese Spring Festival Holiday during 02/11/2021-02/17/2021. Sorry I am temporarily unable to verify your issue on a physical printer. I just printed your pdf file to "Microsoft Print to PDF", but I can not reproduce your issue. Anyway, once we come back to work on Feb 18, 2021, I will do more tests on our physical printer and keep you informed about further testing result. Thanks for your understanding.

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Thu Feb 18, 2021 11:03 am

Hello,

Thank you for sharing your project.
I used Adobe, DevExpress and our Spire to print your pdf file to HP ColorLaserJet MFP printer, the effects are exactly the same, Please check the comparison picture I attached. Have you verified the HP printer?
In addition, here is another way to print the PDF using XpsPrintHelper. You could also have a try to check if there is any change. Attached the XpsPrintHelper package and testing code as below.
Code: Select all
MemoryStream ms = new MemoryStream();
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("TestDoc.pdf");
doc.SaveToStream(ms, FileFormat.XPS);
ms.Position = 0;
XpsPrint.XpsPrintHelper.Print(ms, "your printer name", "Print", true);


Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Thu Feb 18, 2021 3:58 pm

Hi,
The images you sent appear to have been printed in "fit to page" mode, and not "actual size". I can tell because of the huge margin at the top of the page. I wish I could use "fit to page" mode, but I can't. My document has to be printed actual size so it aligns with the perforation for the detachable coupon at the bottom of the production form.

I've attached three images. The first image is a screenshot of the document as it appears in Adobe Acrobat. The printed document should match more or less exactly this image, including margins and the position of the text relative to the margins.

The second image is a scan of the page printed by Adobe Acrobat. Please notice three things.
1. The script "John" and the word "TAX" appear below the top edge of the page.
2. The numbers "1 01236000000 2020 4" appear exactly 6mm above the bottom edge of the page.
3. The printed page matches the screenshot more or less exactly.

The third image is a scan of the page printed by Spire via the test app I sent you. Please notice three things.
1. The script "John" is clipped, and the word "TAX" is gone completely. When printed correctly, the top of the "J" in "John" should be exactly 3mm from the top edge of the page.
2. The numbers "1 01236000000 2020 4" appear exactly 11mm above the bottom edge of the page, i.e. 5mm higher than they should be.
3. It appears that the document is simply printed about 5mm higher on the page than it should be.

We have tested on multiple physical printers. Adobe prints correctly on all. Spire prints incorrectly on all.

This problem is becoming urgent, as we have customers waiting on delivery. Please let me know how I can help you reproduce the problem, and hopefully find a solution.

Thank you!

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Fri Feb 19, 2021 10:28 am

Hello,

Thanks for your feedback.
The comparison image I before provided was using the "actual size" mode of your code. Meanwhile, according to your code, I also printed your pdf file to Microsoft XPS Document Writer, the attached xps file is my testing result. How about the result when you print to Microsoft XPS Document Writer? If the issue still exists, please share us with your system information(E.g. Win7, 64 bit) and the region setting (E.g. China, Chinese) to help further investigate. And actually our internal printing mechanism is used the .NET printing API, you also can use the .NET printing API to print directly, like the below code.
Code: Select all
public static void Print()
{
    PrintDocument printDocument1 = new PrintDocument();
    var printerSettings = new System.Drawing.Printing.PrinterSettings();
    printerSettings.PrinterName = "PrinterName";
    printDocument1.PrinterSettings = printerSettings;
    printDocument1.PrintPage += PrintDocument1_PrintPage;
    printDocument1.Print();
}
public static void PrintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    e.Graphics.DrawString("Test print", new Font("Arial", 10), Brushes.Black, 100, 20);
    e.Graphics.PageUnit = GraphicsUnit.Inch;
}

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Fri Feb 19, 2021 4:33 pm

Hi,

I'm sorry to say the document as rendered into an XPS file is 100% unacceptable. I don't seem to be able to communicate to you what the problem is, and how Spire is failing. A correctly rendered document will meet these requirements:

1. The top edge of the document must start 3mm from the top edge of the page.
2. The bottom edge of the document must be 6mm from the bottom edge of the page.


Please print the document and use a ruler to measure and demonstrate that Adobe Acrobat renders the document correctly, and that Spire does not.

This is not a printing problem per se, it is a rendering problem, and Spire is clearly and demonstrably rendering the document incorrectly.

All the computers in use are Win10, USA English.

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Sat Feb 20, 2021 4:05 am

Hello,

Thanks for your feedback and sorry for the inconvenience caused.
After printing to our physical printers(HP ColorLaserJet MFP and HP LaserJet P1007) in Win10, USA English enviroment, the output is same as the screenshot that I before shared. Sorry I still can't reproduce your issue. According to our developers analysis, your issue may be related to the printer. Anyway, our developers are doing more researches on the internal code and try to give you an adjusted version to make you verify on your printers. We have given the issue the highest priority. Once there is any progress, I will let you know you immediately. Thanks for your understanding.

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Sat Feb 20, 2021 11:03 pm

Hi,

I have attached four annotated images that I hope will help clarify the problem I am having. All four are scans of a printed document.

1.AcrobatOnBrother9450.jpg
This represents the desired output. The pdf file was loaded into Adobe Acrobat and printed "actual size" on a Brother 9450 printer. There is exactly 3mm of space at the top of the document above the "John" image. There is exactly 6mm of space below the numbers at the bottom of the page. This is what the printed pdf looks like when it is correctly printed actual size. If you do not have 3mm space above and 6mm below, the document has not been correctly printed actual size.

2.SpireOnHPLaserjetM29w.jpg
The is what SpirePDF produces when the pdf is printed on an HP LaserJet M29w. Note that the "John" image is clipped, and there is 11mm of space below the numbers at the bottom of the page. No amount of adjusting or altering the PrintSettings has corrected the problem.

3.SpireOnBrother9450.jpg
The is what SpirePDF produces when the pdf is printed on a Brother 9450. The image is identical to what was produced by the HP Laserjet M29w. We have tested on other printers with the same result. The problem has nothing to do with the physical printer. SpirePDF produces erroneous results on all of them, Adobe Acrobat produces correct results on all of them. I can't help but think that this problem represents a latent bug in SpirePDF. If I had to guess, I would say SpirePDF is having trouble with the CropBox or the MediaBox.

4.SpireScaleToFitOnBrother9450.jpg
I have included this to clarify a potential misunderstanding. You included some images in this ticket that were said to indicate that all tools were producing the same actual size printed result. In fact, those images all appear to represent "scale to fit" printing. "Actual size" will give a 3mm space at the top and a 6mm space at the bottom. Even if you used PdfSinglePageScalingMode.ActualSize, somewhere in the pipeline the choice was apparently made to scale to fit. In any case, if you have 10mm of space at the top and 10mm space at the bottom, your printed pdf is scaled to fit, not actual size.

I very much appreciate your perseverance in finding a solution to this problem. I will provide whatever additional info or other help you require.

Thank you!
Last edited by tbomgardner on Sat Feb 20, 2021 11:06 pm, edited 1 time in total.

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Sat Feb 20, 2021 11:04 pm

Your system is limited to 3 attachments. Here is the fourth.

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Mon Feb 22, 2021 9:05 am

Hello,

Thank you for sharing more details.
Our Dev team colleagues are doing their best to analyse the possible reason now. Once there is any progress, we will inform you immediately. Thanks for your patience.

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Tue Feb 23, 2021 6:00 pm

I replied to the 2021.02.23 email from Sofia Yang containing the link to spire.pdf_7.2.11.zip. This new version of SpirePDF did not solve the problem.

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Thu Feb 25, 2021 10:03 am

Hello,

Thanks for your feedback.
Our developer are further investigating the issue. Thanks for your understanding. Meanwhile, have you tested to print a string directly with .NET printing API, like the attached screenshot we suggested previously? How about the print result?

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Thu Feb 25, 2021 3:26 pm

Printing a string worked fine, but it is not related to my problem. My only need is to be able to correctly print the test document I sent you.

tbomgardner
 
Posts: 14
Joined: Wed Jun 10, 2020 4:11 am

Return to Spire.PDF

cron