Free Support Forum -

Exception trying to split word document into single page documents


I tried splitting the word document via pdf route. But it is giving me exception for large documents. Please find my code :

public class WordSplitViaPdf {

public static void main(String... args) throws Exception {

    com.aspose.pdf.License license = new com.aspose.pdf.License();
    com.aspose.words.License wordLicense = new  com.aspose.words.License();

    PdfSaveOptions options = new PdfSaveOptions();
    com.aspose.pdf.DocSaveOptions docSaveOptions = new com.aspose.pdf.DocSaveOptions();

    Document document = new Document("/home/sauravarora/data/1005/bulkupload/contracttemplate/1404/1523299617685/docWithoutContent.docx");
    String folder = "/home/sauravarora/data/1005/bulkupload/contracttemplate/1404/1523299617685";

    for (int page = 1; page <= document.getPageCount(); page++) {
        options.setPageIndex(page - 1);
        FileOutputStream fileOutputStreamForPdf = new FileOutputStream(folder + "/" + page + ".pdf");, options);
        FileOutputStream fileOutputStreamForWord = new FileOutputStream(folder + "/" + page + ".docx");
        FileInputStream fileInputStreamForPdf = new FileInputStream(folder + "/" + page + ".pdf");
        com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(fileInputStreamForPdf);, docSaveOptions);


Also the exception trace :

Exception in thread “main” java.lang.IllegalStateException: Infinite loop detected.
at com.aspose.words.zzYX9.zzAh(Unknown Source)
at com.aspose.words.zzYX9.zzRE(Unknown Source)
at com.aspose.words.zz9E.zzXv(Unknown Source)
at com.aspose.words.zz9F.zz5E(Unknown Source)
at com.aspose.words.zzZN8.zz5E(Unknown Source)
at com.aspose.words.zz1V.zzZWW(Unknown Source)
at com.aspose.words.zz1V.zzZ(Unknown Source)
at com.aspose.words.zz1V.zzZG(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at Source)
at com.aspose.words.examples.cellsexamples.WordSplitViaPdf.main(

I am attaching the document for your reference. Please (12.6 KB)


I was able to resolve this by upgrading the jars to latest version. But a problem i want to get the solution is the page size of certain spitted word documents. They are being spitted into 2 page documents. I am attaching the document for your reference . Please help. We are currently live with aspose with a paid (29.4 KB) (12.6 KB)


Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to PDF. Please refer to the following article:

How Aspose.Words Uses True Type Fonts

Could you please share the page number of document that is exported into two pages?