Free Support Forum -

Pdf to html conversion fails- msg="Comparison method violates its general contract!"

I’m using Aspose.pdf.10.0.0-jdk6. When I try convert the attached pdf to html, it fails with the stacktrace below.

The code to convert is simple and works for other pdfs, but not for this particular pdf.
static void pdfToHtml(String name, byte[] bytes, boolean ppt) throws IOException {
ByteArrayInputStream inStream = new ByteArrayInputStream(bytes);
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(inStream);
int pageCount = doc.getPages().size();“pdfToHtml name=%s, pageCount=%d”, name, pageCount));
com.aspose.pdf.HtmlSaveOptions saveOptions = new com.aspose.pdf.HtmlSaveOptions();
saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
String suffix = ppt? “-ppttopdf.html”: “-frompdf.html”;
String docName = outputDirectory + “\” + name + suffix;, saveOptions);

[THREAD=main] 2015-03-12 16:07:49 INFO AsposeTest:482 - pdfToHtml name=Journal of Chemistry, pageCount=13
[THREAD=main] 2015-03-12 16:08:05 WARN Utils:28 - java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi( at java.util.TimSort.mergeHi(
at java.util.TimSort.mergeAt(
at java.util.TimSort.mergeForceCollapse(
at java.util.TimSort.sort(
at java.util.Arrays.sort(
at com.aspose.pdf.internal.p302.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p44.z21.m12(Unknown Source)
at com.aspose.pdf.internal.p44.z21.m1(Unknown Source)
at com.aspose.pdf.internal.p44.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p42.z1.m2(Unknown Source)
at com.aspose.pdf.internal.p42.z1.m3(Unknown Source)
at com.aspose.pdf.internal.p42.z5.m4(Unknown Source)
at com.aspose.pdf.internal.p39.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p39.z1.m3(Unknown Source)
at com.aspose.pdf.internal.p39.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p39.z1.m2(Unknown Source)
at com.aspose.pdf.internal.p39.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p38.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p217.z7.m1(Unknown Source)
at com.aspose.pdf.internal.p217.z7.m1(Unknown Source)
at com.aspose.pdf.z77.m1(Unknown Source)
at Source)
at Source)
at asposetest.AsposeTest.pdfToHtml(
at asposetest.AsposeTest.doCustomHtmlConversion(
at asposetest.AsposeTest.doFile(
at asposetest.AsposeTest.doDirectory(
at asposetest.AsposeTest.doDirectory(
at asposetest.AsposeTest.main(

Hi Andy,

Thanks for your inquiry. I have tested your scenario with your shared document using Aspose.Pdf for Java 10.0.0 and managed to observe the reported exception. For further investigation, I have logged an issue in our issue tracking system as PDFNEWJAVA-34750 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Please feel free to contact us for any further assistance.

Best Regards

The issues you have found earlier (filed as PDFNEWJAVA-34750) have been fixed in Aspose.Pdf for Java 10.4.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.