We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Shape to HTML/JPEG other formats giving Heap Space Error


I am using Aspose Diagram for Java 5.9.0.

when I try to Copy shape from one Visio File to other and export it in HTML/JPEG/PNG format i am getting Java Heap Space Error.

PFA source Code file and Source Visio Document being used.

Shubhi Sood

Hi Shubhi,

Thank you for contacting support. Please note after setting the drawing scale of the Visio, it does not throw a Java Heap Space Error. Please refer to the answer that I replied in your another forum thread:


Is there any way to trim white spaces that is coming in PDF output even after setting page size of new Diagram.

Also rather than cloning shape output from one Visio File to another can we have Diarect API which could conver shape to other output Formats.

For Example: Rather than cloning to new Visio file if we can have method such as shapeToPDF / shapeToHTML .

Shubhi Sood

Hi Shubhi,

Thank you for clarifying the use case. Please check that how you can save a single shape in the PDF format:

double shapeWidth = 0;
double shapeHeight = 0;

// load Visio diagram
Diagram srcVisio=new Diagram(“C:/AD/test558/MeetRoom.vsd”);
// get Visio page
Page srcPage = srcVisio.getPages().get(1);
// remove background page

// get hash table of shapes, it holds id and name
Hashtable<Long, String> remShapes = new Hashtable<Long, String>();
for (Shape shape : (Iterable)srcPage.getShapes())
// for Normal Shape
remShapes.put(shape.getID(), shape.getName());
// iterate through the hash table
Enumeration enumKey = remShapes.keys();
Long key = enumKey.nextElement();
String val = remShapes.get(key);
Shape shape = srcPage.getShapes().getShape(key);
// check of the shape name
// move shape to the origin corner
shapeWidth = shape.getXForm().getWidth().getValue();
shapeHeight = shape.getXForm().getHeight().getValue();
shape.moveTo(shapeWidth0.5, shapeHeight0.5);
// trim page size
// remove shape from the Visio page and hash table

// specify saving options
// use HTMLSaveOptions class to save in the HTML
PdfSaveOptions opts = new PdfSaveOptions();
// set page count to save
// set starting index of the page
// save it
srcVisio.save(“C:/AD/test558/PDFOut14.pdf”, opts);

Similarly, you can use the HTMLSaveOptions class to save a Visio shape in the HTML. Please let us know in case of any confusion or questions.