Hi Tahir,
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();
license.setLicense(new java.io.FileInputStream("/home/sauravarora/Desktop/aspose-licence"));
wordLicense.setLicense("/home/sauravarora/Desktop/aspose-licence");
PdfSaveOptions options = new PdfSaveOptions();
com.aspose.pdf.DocSaveOptions docSaveOptions = new com.aspose.pdf.DocSaveOptions();
docSaveOptions.setMode(com.aspose.pdf.DocSaveOptions.RecognitionMode.Flow);
docSaveOptions.setFormat(com.aspose.pdf.DocSaveOptions.DocFormat.DocX);
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);
options.setPageCount(1);
FileOutputStream fileOutputStreamForPdf = new FileOutputStream(folder + "/" + page + ".pdf");
document.save(fileOutputStreamForPdf, 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);
pdfDocument.save(fileOutputStreamForWord, 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 com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.examples.cellsexamples.WordSplitViaPdf.main(WordSplitViaPdf.java:30)
I am attaching the document for your reference. Please help.docWithoutContent.docx.zip (12.6 KB)