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 15, 2023 8:01 am

Hello

We have a problem when trying to extract image from a PDF.
The images that we get from the page method are not complete : it's as if the image was translated outside of the canvas.
The extracted images have a transparent part, and some of the original image translated.
The page is rotated 270 degrees

Original PDF attached, as well as first and last image as extracted

we are using Spire Office for java, version 7.9.6

Code :
Code: Select all
PdfPageCollection pages = document.getPages();
for (int i = 0; i < pages.getCount(); i++) {
   PdfPageBase page = pages.get(i);
   if (page != null) {
      double pageWidth = page.getCanvas().getClientSize().getWidth();
      double pageHeight = page.getCanvas().getClientSize().getHeight();
      PdfPageRotateAngle rotation = page.getRotation();
      // get infos on imges in page
      PdfImageInfo[] infos = page.getImagesInfo();               
      if (infos != null) {
         for (PdfImageInfo pdfImageInfo : infos) {
            BufferedImage sourceImage = pdfImageInfo.getImage();
            
            File output = new File("C:\\Users\\guipatry\\Documents\\Development\\ImageExtractor\\datas\\"
                                                   + String.format("Image_%d_%d.png", i, pdfImageInfo.getIndex() ));
                          try {
               ImageIO.write(sourceImage, "PNG", output);
            } catch (IOException e) {
            }
         }
      }
   }
}


Regards
Guillaume PATRY

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

Fri Jun 16, 2023 9:10 am

Hello,

Thanks for your inquiry.
I tested your PDF file and did reproduce the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREPDF-6073. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Fri Jul 07, 2023 7:24 am

Hello,

Thank you for your patience!
Glad to inform you that we just released Spire.PDF for Java Version:9.7.0, which fixed your issue SPIREPDF-6073. Please use this version to test.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Return to Spire.PDF

cron