ArrayIndexOutOfBoundsException when calling Document.save()

Hello,

I try to convert a .docx document to PDF using Aspose Words for Java (aspose-words-18.2-jdk16.jar), and it fails with the stack trace

java.lang.ArrayIndexOutOfBoundsException: 29436
    at asposewobfuscated.zzFL.zzY(Unknown Source)
    at asposewobfuscated.zzCM.zzZ(Unknown Source)
    at asposewobfuscated.zzCM.zzZ(Unknown Source)
    at asposewobfuscated.zzRJ.zzY(Unknown Source)
    at asposewobfuscated.zzHY.zzY(Unknown Source)
    at asposewobfuscated.zzI1.zzZ(Unknown Source)
    at asposewobfuscated.zzIP.zzT(Unknown Source)
    at asposewobfuscated.zzIR.endDocument(Unknown Source)
    at asposewobfuscated.zzH1.endDocument(Unknown Source)
    at com.aspose.words.zzZ53.zzZUy(Unknown Source)
    at com.aspose.words.zzZY9.zzZ(Unknown Source)
    at com.aspose.words.zzZFJ.zzZ(Unknown Source)
    at com.aspose.words.Document.zzZ(Unknown Source)
    at com.aspose.words.Document.zzZ(Unknown Source)
    at com.aspose.words.Document.save(Unknown Source)
    at com.aspose.words.Document.save(Unknown Source)

The problem occurs in more than one file (so far, I’ve found 27 different .docx files that have it). My code is as follows:

import com.aspose.words.Document;
...
public static void convertWords(String inputFileName, String outputFileName) throws Exception {
    FontSettings fontSettings = new FontSettings();
    fontSettings.setFontsFolders(new String[] { Main.fontFolder }, false);
    Document doc = new Document(inputFileName);
    doc.setFontSettings(fontSettings);
    doc.save(outputFileName);
}

It looks like this problem originates from Aspose Words 17.3, since all these files can be converted using Aspose Words 17.2 but not 17.3.

Could you please help me with this?

Thanks!

@shutovich,

Please ZIP and upload your Word documents (you are getting this problem with) here for testing. We will investigate the issues on our end and provide you more information.

Most of the files are unpublished manuscripts, but there is one .doc file I can share that causes the same problem. Please see article_1.doc.zip.

For an example of the same problem with .docx file, please see article_2.docx.zip.

@shutovich,

Thanks for your inquiry. After an initial test with Aspose.Words for Java 18.2, we were unable to reproduce this issue on our end. We used the following code for testing on our end.

FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolders(new String[] { "C:\\Windows\\Fonts" }, false);
Document doc = new Document("D:\\temp\\article_1.doc");
doc.setFontSettings(fontSettings);
doc.save("D:\\temp\\article_1-awjava-18.2.pdf");

Please find below the Output PDF files:

Please double check that you are indeed using the latest version of Aspose.Words for Java i.e. 18.2 on your end.

Looks like the problem has been caused by the font Cyberbit.ttf. Once I removed this file from the fonts folder, all 27 .docx files are converted without problems. However, with this file in the folder, all files fail with ArrayIndexOutOfBoundsException error.

@shutovich,

Please ZIP and upload this problematic font file here for further testing.

It looks like the font file is too large to be attached here (zipped file size is 6 MB), but Google search has found the web page http://packages.nanobox.io/2017/11/base/cyberbit-ttf-2.0nb7.tgz.html that has link to the package with this font (I’ve downloaded and extracted Cyberbit.ttf from this package, and its md5 checksum matches my file).

@shutovich,

We have installed this “Cyberbit.ttf” font file on 64-bit Windows 10 and I am afraid, we are still unable to reproduce this issue on our end. The results are same as mentioned in my earlier post. We tested the scenario with Aspose.Words for Java 18.3 by using jdk1.8.0_51. If we can help you with anything else, please feel free to ask.