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 Nov 26, 2021 2:36 pm

Hello
I got 2 PDF that I try to concatenate. When doing so everything is OK. However, if I try to compress the images using TryCompressImage (as shown in the code example), the resulting images are corrupted. (size is different in images due to zoom during the screenshot. It does not seems different in the files)

GuiPATRY
 
Posts: 21
Joined: Wed Feb 17, 2021 10:18 am

Mon Nov 29, 2021 2:05 am

Hello,

Thanks for your inquiry.
I simulated a PDF and tested the TryCompressImage method with our latest Spire.PDF Pack(Hot Fix) Version:7.11.1, but I didn't reproduce your issue. The image of output PDF displayed correctly. Below is my testing code. I also attached the output PDF for your reference.
Code: Select all
 PdfDocument doc = new PdfDocument();
 doc.LoadFromFile(@"input.pdf");
 //Disable the incremental update
 doc.FileInfo.IncrementalUpdate = false;
 //Traverse all pages
 foreach (PdfPageBase page in doc.Pages)
 {
     if (page != null)
     {
         if (page.ImagesInfo != null)
         {
             foreach (PdfImageInfo info in page.ImagesInfo)
             {
                 page.TryCompressImage(info.Index);
             }
         }
     }
 }
 //Save the document
 doc.SaveToFile(@"output.pdf");

If you were using an old version, I suggest you first try again with the latest one. If your issue still exists after trying, to help further look into the caused reason. please share us with the following more information. Thanks in advance.
1. Your testing PDF.
2. Your system information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese).
3. The target platform of your project(E.g. NET framework 4.7.2).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Nov 29, 2021 7:21 am

Hello

Please find in the ZIP the 2 PDF I'm trying to concatenate.
Note that for most of the PDF we concatenate, the image compression is working fine. But for some cases, such as those 2, it does not.

We use the latest Java version of Office Spire (as we just bought the library), on a windows NT (test) machine, with a European region setting (France).
The code we use is similar to your (in java), copied from the tutorial.

Code: Select all
      PdfPageCollection pages = document.getPages();
      for (int i = 0; i < pages.getCount(); i++) {
         PdfPageBase page = pages.get(i);
         if (page != null) {
            PdfImageInfo[] infos = page.getImagesInfo();
            if (infos != null) {
               for (PdfImageInfo pdfImageInfo : infos) {
                  page.tryCompressImage(pdfImageInfo.getIndex());
               }
            }
         }
      }


Thanks & regards
Guillaume PATRY

GuiPATRY
 
Posts: 21
Joined: Wed Feb 17, 2021 10:18 am

Mon Nov 29, 2021 10:20 am

Hello,

Thank you for sharing.
I indeed reproduced your issue when testing with our Spire.Office for Java. This issue has been logged into our bug tracking system with the ticket SPIREPDF-4816. Our Dev team will further investigate and fix it. Once it is fixed, we will provide a hotfix version for you. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Jan 17, 2022 12:22 pm

Hello

Do you have any idea of when this may be solved ?
I would like to know if I should move to prod without the optimization, or wait for the solution.

Thanks
Guillaume

GuiPATRY
 
Posts: 21
Joined: Wed Feb 17, 2021 10:18 am

Tue Jan 18, 2022 7:40 am

Hello Guillaume,

Thank you for following up.
The issue SPIREPDF-4816 has been resolved. At present the fixing was included in latest Spire.PDF for Java Version:5.1.1. You can test it first. Once our Spire.Office for Java version includes the fixing. I will inform you immediately.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Fri Jan 21, 2022 9:45 am

Hello,

Glad to inform that we just released Spire.Office for Java 5.1.5 which includes the fixing of SPIREPDF-4816, welcome to download and test it.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Jan 25, 2022 7:29 am

Hello,

Greetings from E-iceblue.
Did the new version work for you? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Jan 25, 2022 7:57 am

Hello
Our tests show that the problem is solved.

Thanks
Guillaume

GuiPATRY
 
Posts: 21
Joined: Wed Feb 17, 2021 10:18 am

Tue Jan 25, 2022 9:11 am

Hello,

Glad to hear that! If you encounter any issues related to our products in the future, just feel free to contact us.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF