We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page.getColorType hangs or throws StackOverflowError

Sample_Hang.pdf (243.2 KB)
Sample_StackOverflow.pdf (88.9 KB)

Aspose Team,
We use the Aspose PDF java package to get the color types of PDF files. However, the Page.getColorType method hangs or throws StackOverflowErrorm (see below) with some PDF files.

Exception in thread “main” java.lang.StackOverflowError
at sun.java2d.loops.Blit.Blit(Native Method)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3320)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3298)
at com.aspose.pdf.internal.l52n.l1v.lI(Unknown Source)
at com.aspose.pdf.internal.l52n.l1v.lI(Unknown Source)
at com.aspose.pdf.internal.l52n.l1v.lI(Unknown Source)
at com.aspose.pdf.internal.l11l.ld.(Unknown Source)
at com.aspose.pdf.internal.l6if.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l3n.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l3n.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l1y.ld.lI(Unknown Source)
at com.aspose.pdf.XImage.saveInternal(Unknown Source)
at com.aspose.pdf.XImage.lI(Unknown Source)
at com.aspose.pdf.XImage.lI(Unknown Source)
at com.aspose.pdf.XImage.getColorType(Unknown Source)
at com.aspose.pdf.internal.l9k.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l9k.lf.lI(Unknown Source)

Following is the sample code that reproduces the problem and attached are two sample files (one for hang and one for StackOverflowError). The operating system is Ubuntu 18.04. Java version is 1.8 and Aspose PDF java package is 20.8.

import com.aspose.pdf.Document;
import com.aspose.pdf.Page;

public class GetColorType {
public static void main(String[] args) {
System.out.println(“Start”);
try {
String path = “/home/ubuntu/testdir_colortype/Sample_Hang.pdf”;
com.aspose.pdf.Document pdfDoc = new Document(path);
Page page = pdfDoc.getPages().get_Item(1);
int colotType = page.getColorType();
System.out.println("colotType = " + colotType);
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println(“Done”);
}
}

@xyang

We tested the scenario using Aspose.PDF for Java 20.8 in a Windows environment and faced an exception i.e. java.lang.NullPointerException with the file Sample_StackOverFlow.pdf whereas, other file caused the program to hang up. We have logged the following issues in our issue tracking system:

  • PDFJAVA-39735 - Exception is thrown
  • PDFJAVA-39736 - Program hung

We will further look into details of these issues and keep you informed about their rectification status. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-39736,PDFJAVA-39735) have been fixed in Aspose.PDF for Java 21.6.