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.

Wed Aug 17, 2022 7:05 am

Hi.
I have a document which I will load it from MemoryStream and try to print. The problem is that the MemoryStream has 815KB but when I look in the printer dialog the size of the document grows to 21 MB, which take a long time for printer to load it in memory. Inside this document I have 30 barcodes as images draw on canvas, which I need them in high resolution.
Why this happens?

Code I used to print the stream:
Code: Select all
// SablonCompletat is a MemoryStream of 815KB in size
using Spire.Pdf.PdfDocument pdf = new(SablonCompletat);
// pdf.SaveToFile(fileToPrintTo);  it creates a file with the same size as MemoryStream.

Printing.PrinterSettings ps = new();
Printing.PageSettings pgs = new();
Printing.PrintDocument prtdoc = new();

//Set printer name
ps.PrinterName = PrinterName;
ps.Copies = PrinterCopies;

//Set PageSize (if required)
pgs.PaperSize = new Printing.PaperSize("A4", 827, 1169);

// Set PageMargins (if required)
pgs.Margins = new Printing.Margins(0, 0, 0, 0);

// Print document using printer and page settings
pdf.PrintSettings.PaperSize = pgs.PaperSize;
pdf.PrintSettings.Copies = PrinterCopies;
pdf.PrintSettings.PrinterName = PrinterName;
pdf.PrintSettings.SetPaperMargins(5, 5, 0, 0);
//pdf.PrintSettings.PrinterResolutionKind = Spire.Pdf.Print.PdfPrinterResolutionKind.Draft; // I've tried different values, same out size
pdf.PrintSettings.PrintController = new StandardPrintController();
pdf.Print();

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Wed Aug 17, 2022 7:42 am

Hello,

Thanks for your inquiry.

Based on your description, I guess these barcodes images in the PDF are all grayscale color space. When Spire.Pdf prints or converts the formats, they will be uniformly decoded and then re-encoded in the RGB color space. This will indeed increase the size of the document data. Hope you can understand.
If the situation is not what I guess, but the data is still growing when printing. To help us reproduce and investigate this issue, could you please share your test PDF with us? You can upload it here or send it to us via email (support@e-iceblue.com). Thanks in advance for your assistance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed Aug 17, 2022 8:11 am

The file is in attachement

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Thu Aug 18, 2022 9:50 am

Hi,

Thanks for your sharing.

I tested your document with a virtual printer (Microsoft XPS Document Writer), but the total document size in the printer dialog is the normal 768KB. Due to the overheating weather, I did not go to my company today but worked at home. So I am temporarily unable to verify the document with a physical printer. I will verify it further tomorrow and let you know the result.
By the way, I'm not sure if the version of Spire.Pdf you're using makes any difference. So if the Spire.Pdf you are using is not the latest 8.8.6 version, I suggest you update to the latest version and verify the issue again.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Tue Aug 23, 2022 6:57 am

Andy.Zhou wrote:Hi,

Thanks for your sharing.

...
By the way, I'm not sure if the version of Spire.Pdf you're using makes any difference. So if the Spire.Pdf you are using is not the latest 8.8.6 version, I suggest you update to the latest version and verify the issue again.


I'm using Free SpirePDF, because I use only one page in pdf files everytime, I don't need more than what free version offers (BTW, thanks for free version).
My PDF files contains only some textbox widgets which I have to fill them programmatically. It is a one-page document, as you could see, it contains labels for some items/products.
I know free Spire does not get updates as paid version does, but if this problem will not be solved, I must find some other products that fills my needs, without paying. It's not worth to pay such amount for one page job :)

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Thu Aug 25, 2022 9:08 am

Hi.
8 days and no concrete answer.
Please, I need an answer.
Thanks

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Thu Aug 25, 2022 9:23 am

Dear sir,

Sorry for the late reply.

I have tested the issue with a physical printer and the data size is 9.13MB which Spire.Pdf post to the printer. While it's not as much as the 21M you mentioned, it does make a big increase from the ogrinal file size. I have logged this issue in our bug track system with the ticket SPIREPDF-5437. The development team will investigate and optimize it further. I will keep you informed of relevant developments and updates.
But unfortunately, the free version is updated less frequently. We just update it from time to time. Therefore, if this issue is later optimized, I can't guarantee you when it will be added to the free version. Hope you can understand.
Apologize again for the late reply.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Aug 25, 2022 1:05 pm

I understand, as long as I use free version, and I see free version is not updated as much as paid one, but is better to know that is an internal issue and not only on my side. Maybe there will be an workaround for free version too, untill free version will get the update, please let me know.

Thanks and best regards,
Vali

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Fri Aug 26, 2022 9:25 am

Dear Vali,

Thanks for your understanding and reply.

Yes I will notify you in time when the solution is added into the free version.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon Oct 17, 2022 7:32 am

Andy.Zhou wrote:Dear Vali,

Thanks for your understanding and reply.

Yes I will notify you in time when the solution is added into the free version.


Hi Andy. Did the last update of free version solved this issue? (8.6.0)

Edit:
I've made some test and seems to be the same issue with new version...

Thank you.

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Tue Oct 18, 2022 10:26 am

Hello,

Thanks for your following-up.
This is Abel from E-iceblue support team. I created a console project with .Net framework4.8 and used the FreeSpire.Pdf8.6.0 and the following code to test your scenario, however, the data size is 1.01MB which SpirePdf post to the physical printer. What the data size that SpirePdf post to the physical printer on your side? And what data size you excepted? In addition, what is the model of your physical printer? My physical Printer is “HP Color LaserJet MFP M281fdw”.
Code: Select all
 PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(@"../../data/54f948d4-f1ff-4382-a110-0554a99b6e37.pdf");

            // Print document using printer and page settings
            pdf.PrintSettings.PaperSize = new PaperSize("A4", 827, 1169);
           pdf.PrintSettings.PrinterName = "HP Color LaserJet MFP M281fdw";
           pdf.PrintSettings.SetPaperMargins(5, 5, 0, 0);
            pdf.PrintSettings.PrinterResolutionKind = Spire.Pdf.Print.PdfPrinterResolutionKind.High; // I've tried different values, same out size
            pdf.PrintSettings.PrintController = new StandardPrintController();
            pdf.Print();


Sincerely
Abel
E-iceblue support team
Last edited by Abel.He on Wed Oct 19, 2022 2:51 am, edited 1 time in total.
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 18, 2022 10:41 am

Abel.He wrote:Hello,

Thanks for your following-up.
This is Abel from E-iceblue support team. I created a console project with .Net framework4.8 and used the FreeSpire.Pdf8.6.0 and the following code to test your scenario, however, the data size is 1.01MB which SpirePdf post to the physical printer. What the data size that SpirePdf post to the physical printer on your side? And what data size you excepted? In addition, what is the model of your physical printer? My physical Printer is “HP Color LaserJet MFP M281fdw”.

Sincerely
Abel
E-iceblue support team


Hi Abel.
As Andy.Zhou also said earlier, his tests also increased the size of spooled document in his printer to 9.1 MB, of a small document (<1MB). I have an attachment in this thread somewhere up in the posts with a sample document. This document contains texts and images. When I sent it to printer the printer spooled size is somewhere near the 19 MB, and the document size is about 1MB. Could you test with the sample document I sent please?

PS: My both printers (Lexmark MX 711 and HP CP3505 Color) both spooled size is the same, about 19 MB.

Regards,
Vali

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Wed Oct 19, 2022 9:49 am

Hello,

Thanks for your feedback.
Yes, it was the pdf document you provided that I tested yesterday. After communicating with our development team, the issue is most likely related to the system environment. My test environment is Win10 -64bit, RAM-16g. You can test the printing scenario in different system environments to see the data size that SpirePdf post to the physical printer.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Wed Oct 19, 2022 1:27 pm

Abel.He wrote:Hello,

Thanks for your feedback.
Yes, it was the pdf document you provided that I tested yesterday. After communicating with our development team, the issue is most likely related to the system environment. My test environment is Win10 -64bit, RAM-16g. You can test the printing scenario in different system environments to see the data size that SpirePdf post to the physical printer.

Sincerely
Abel
E-iceblue support team

Hi Abel,
I test it in 3 different OS-es... My OS - Win 11 x64 16 GB RAM, the second one is a W7 x64, 4GB Ram and the third was on a virtual machine with Windows 10 x64, 6GB Ram... The same issue on all systems, so I don't think it is a OS related issue. And four printers was involved, my those two printers I said about them in last post, another Lexmark 5xx series and Microsoft PDF Printer as well... I don't know where to test it anymore :(

PS: This is the code I use, maybe is something wrong with it, I don't know:
Code: Select all
                // SablonCOmpletat is a MemoryStream with the pdf file (my template) after is populated with data which have the size of the pdf file, I've test it and I see  it in debugger too.
                using Spire.Pdf.PdfDocument pdf = new(SablonCompletat);
                // Create objects for printer and page settings and PrintDocument
               
                Printing.PrinterSettings ps = new();
                Printing.PageSettings pgs = new();
                Printing.PrintDocument prtdoc = new();

                // Set printer name
                ps.PrinterName = PrinterName;
                ps.Copies = PrinterCopies;

                // Set PageSize (if required)
                pgs.PaperSize = new Printing.PaperSize("A4", 827, 1169);

                // Set PageMargins (if required)
                pgs.Margins = new Printing.Margins(0, 0, 0, 0);

                // Print document using printer and page settings
                pdf.PrintSettings.PaperSize = pgs.PaperSize;
                pdf.PrintSettings.Copies = PrinterCopies;
                pdf.PrintSettings.PrinterName = PrinterName;
                pdf.PrintSettings.SetPaperMargins(5, 5, 0, 0);
                pdf.PrintSettings.PrinterResolutionKind = Spire.Pdf.Print.PdfPrinterResolutionKind.Low;
                pdf.PrintSettings.PrintController = new StandardPrintController();

                // Test FileSize
                //pdf.SaveToFile(@"D:\FisierDeTest.pdf");
                //Debug.WriteLine($"Fisierul ar trebui sa aiba: {SablonCompletat.Length} bytes");

                //pdf.LoadFromFile(@"D:\FisierDeTest.pdf");
                pdf.Form.IsFlatten = true;
                pdf.Print();



Regards,
Vali

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Thu Oct 20, 2022 10:26 am

Hello,

Thanks for your feedback.
I have communicated with our development team about the scenario you mentioned, they will do further investigation. Once there are any updates, I’ll inform you in time.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF

cron