Problem when saving large word files

Last post 02-09-2012, 1:17 AM by awais.hafeez. 10 replies.
Sort Posts: Previous Next
  •  02-07-2012, 7:52 AM 359768

    Problem when saving large word files Java

    Hello,

    An "OutOfMemoryError" exception is thrown when I try to update the table of contents and save the word file (28,9 Mo).

    Java argument : -Xms1536m

    Code source :
    LoadOptions lOption = new LoadOptions(LoadFormat.WORD_ML, "", "");
    Document contentsDoc = new Document("contents.doc", lOption);
    Document doc = new Document("document.doc", lOption);

    contentsDoc.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING);

    contentsDoc.updateFields();
    contentsDoc.save("newDocument.docx");


    Exception :
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at com.aspose.words.u.d(BbtNode.java:94)
    at com.aspose.words.s.b(Bbt.java:393)
    at com.aspose.words.asx.g(StoryLayoutBuilder.java:56)
    at com.aspose.words.asv.a(StoryCloner.java:56)
    at com.aspose.words.rk.a(HeaderFooterStories.java:55)
    at com.aspose.words.rl.c(HeaderFooterStoryLayout.java:91)
    at com.aspose.words.aiu.h(PageReflower.java:41)
    at com.aspose.words.ajj.w(PartReflower.java:31)
    at com.aspose.words.asw.fb(StoryLayout.java:90)
    at com.aspose.words.ff.aE(DocumentLayoutBuilder.java:169)
    at com.aspose.words.wc.a(LayoutDocument.java:52)
    at com.aspose.words.Document.updatePageLayout(Document.java:1461)
    at com.aspose.words.ld.perform(ExternalActionUpdateLayout.java:25)
    at com.aspose.words.os.execute(FieldUpdateExecutionItem.java:79)
    at com.aspose.words.ov.if(FieldUpdater.java:97)
    at com.aspose.words.ov.updateFields(FieldUpdater.java:60)
    at com.aspose.words.Range.updateFields(Range.java:172)
    at com.aspose.words.Document.updateFields(Document.java:1047)
    at aspose.task.print.GenerateDocProcessTask.main(GenerateDocProcessTask.java:233)

    How to resolve this problem, please?
     
  •  02-07-2012, 8:11 AM 359773 in reply to 359768

    Re: Problem when saving large word files

    Hi Antoine,

    Thanks for your inquiry. Could you please attach your input documents here for testing? I will investigate the issue on my side and provide you more information.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  02-08-2012, 2:23 AM 359985 in reply to 359773

    Re: Problem when saving large word files

    Attachment: Present (inaccessible)
    Thanks for your quick reply, very much appreciated.

    I have attached the requested documents/files in the attached zip file.
    I look forward to your response.

    Best Regards,

    Patrice ANTOINE
    Filed under: .doc;.docx;Aspose Word;Java
     
  •  02-08-2012, 4:22 AM 360015 in reply to 359985

    Re: Problem when saving large word files

    Attachment: Present (inaccessible)
    Hi Antoine,

    First of all, please note that DocumentExplorer is a very useful tool which easily enables us to see the entire document structure. You can find DocumentExplorer in the folder where you installed Aspose.Words e.g. C:\Program Files (x86)\Aspose\Aspose.Words for .NET\Demos\CSharp\DocumentExplorer\bin\DocumentExplorer.exe. Below is the DOM structure of your document as viewed with DocumentExplorer:

    Provided Word document truncated at the end. To utilize Aspose.Words on its full capacity, you can apply an evaluation license without restrictions for 30 days here.

    I just remove first empty paragraph in second section and exception could not occur again on my side. I have attached input / output Word documents.


    Best Regards,
    Imran Rafique
    Support Developer
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
    Keep in touch! We're on Twitter and Facebook
     
  •  02-08-2012, 5:17 AM 360028 in reply to 360015

    Re: Problem when saving large word files

    Hello,

    Have you really tested my input document?
    because it seems your document is truncated and does not contain 3000 pages.

    I have a temporary licence and it does not truncate the document.

    I don't understand why you have removed the first empty paragraph in second section.

    Could you rerun the test with the complete document (28,9Mo), please?


    Best Regards,
    Patrice ANTOINE
     
  •  02-08-2012, 6:36 AM 360048 in reply to 360028

    Re: Problem when saving large word files

    Hi Antoine,

    Thanks for your inquiry.

    While using the latest version of Aspose.Words i.e. 11.0.0 and your code, I managed to reproduce this exception on my side. Most likely this problem occurs because the document you are trying to append to another document is simply too large. You should note that usually Aspose.Words needs few times more memory than document size to build model of the document (DOM) in memory.

    For example if your document’s size is 1 MB, Aspose.Words needs 10-20 MB of RAM to build its DOM in memory. Multiplier depends on format because some formats are more compact than others. For example DOCX format is more compact than DOC and RTF, and DOC is more compact than RTF.

    So I am not sure the issue you reported can be resolved in Aspose.Words. I would advise you to use few small documents instead of one huge document. Also, please try stopping all running service/programs on your machine while performing this operation (appending, updating fields and then saving).

    Please let me know if I can be of any further assistance.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  02-08-2012, 6:58 AM 360056 in reply to 360028

    Re: Problem when saving large word files

    Attachment: Present (inaccessible)
    Hi Antoine,

    Thank you for inquiry. Moreover, Please view the attached screenshot.

    Here, you can observe input Word document text truncated after 4 pages so the Document Explorer don't recognize whole text (along with 3000 pages).

    In case of any ambiguity, please let me know.


    Best Regards,
    Imran Rafique
    Support Developer
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
    Keep in touch! We're on Twitter and Facebook
     
  •  02-08-2012, 7:45 AM 360072 in reply to 360048

    Re: Problem when saving large word files

    Hi,

    Thanks very much for your replies.

    Do you think I will have the same problem using Aspose.Words for. NET?
    Please, could you test the large word document with Aspose.Words for .Net and tell me if the generated file was working correctly?

    I look forward to your answer.

    Best Regards,
    Patrice ANTOINE
     
  •  02-08-2012, 9:12 AM 360089 in reply to 360072

    Re: Problem when saving large word files

    Hi Antoine,

    Thanks for your request. I was able to successfully perform the desired task (i.e. append/save) on the .Net platform without any exception. I have slightly modified your code below that worked for me:

    Document doc = new Document(@"c:\Aspose\document.doc");
    Document contentsDoc = new Document(@"c:\Aspose\contents.doc");

    contentsDoc.AppendDocument(doc, ImportFormatMode.KeepSourceFormatting);
    contentsDoc.UpdateFields();
    contentsDoc.Save(@"c:\Aspose\out.doc", SaveFormat.WordML);

    However, the exception did occur on my side when I didn't specify SaveFormat in the Save method. 

    If we can help you with anything else, please feel free to ask.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  02-08-2012, 10:25 AM 360117 in reply to 360089

    Re: Problem when saving large word files

    Hi,

    I try to use the "SaveFormat" option with Aspose.Words for java and i append/save the large word file with success.
    I was able to generate the large file (docx, doc and pdf) without any exception.

    Thanks for your time!


    Best Regards,
    Patrice ANTOINE
     
  •  02-09-2012, 1:17 AM 360274 in reply to 360117

    Re: Problem when saving large word files

    Hi Antoine,

    Thanks for your feedback. It is perfect that you managed to resolve the problem on your side. If we can help you with anything else, please feel free to ask.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML