Shape to HTML/JPEG other formats giving Heap Space Error

Hello


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.

Regards
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:
https://forum.aspose.com/t/6710

Hello


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 .

Regards
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:

[Java]
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
srcPage.setBackPage(null);

// 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
System.out.println(shape.getID()+shape.getName());
remShapes.put(shape.getID(), shape.getName());
}
// iterate through the hash table
Enumeration enumKey = remShapes.keys();
while(enumKey.hasMoreElements())
{
Long key = enumKey.nextElement();
String val = remShapes.get(key);
Shape shape = srcPage.getShapes().getShape(key);
// check of the shape name
if(val.equals(“GroupShape1”))
{
// 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
srcPage.getPageSheet().getPageProps().getPageWidth().setValue(shapeWidth);
srcPage.getPageSheet().getPageProps().getPageHeight().setValue(shapeHeight);
}
else
{
// remove shape from the Visio page and hash table
srcPage.getShapes().remove(shape);
remShapes.remove(key);
}
}

// specify saving options
// use HTMLSaveOptions class to save in the HTML
PdfSaveOptions opts = new PdfSaveOptions();
// set page count to save
opts.setPageCount(1);
// set starting index of the page
opts.setPageIndex(1);
// 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.