Question

while converting a docx file in pdf file using Aspose i got this heap size error.here is the code
this docx file is 44Mb

public void convertDoc(String Path, String destPath) throws Exception{


        Document doc = new Document(Path); //At this line heap size error comes
        doc.save(destPath);
        System.out.println("doc converted to pdf");

        }

Any suggestions?

Was it helpful?

Solution

Increasing the heap size should fix the issue.

If it doesn't, then check if you have high resolution images in your Word document. I have converted very large DOC files to PDF (without high res images) under 512 MB memory. But, some of the documents, even less than 50 pages, but having large sized images, they require large memory, even upto 3GB!!

Possible solutions:

  • Replace the images inside your document using Aspose.Words with smaller, resized images
  • If the document has multiple sections, split the document by section and convert to PDF separately. This would of course later require the merging of PDF files.

I work as a Developer/Evangelist at Aspose.

OTHER TIPS

Since you are loading a document larger than the heap size you will have to increase the heap size while running the program like this

 java -Xmx512M myprogram

If you are using eclipse go to Run -> Run Configurations and under Arguments Tab type -Xmx512m and click on RUN

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top