Creating New VSDX file using .VSS

I’m evaluating the Diagram API for Java and I’m looking for a simple boot strap example that will add an image from a vss file and create a vsdx file. after the vsdx file is created using the API I need to be able to manually open the vsdx file in Visio. The code below works but when I open the file in Visio the size of the shape appears very large and does not seem to fit on a page. It seems to span across many pages and doesn’t look to be attached to a page… I’m sorry if this is a simple question but I need to get past this in order to move forward with a recommendation of the product.

I’m hoping this code is somewhat close to the simple task I’m trying to do

public static void main(String[] args) throws Exception {
String dataDir = Utils.getSharedDataDir(AddMasterFromStencil.class) + “Masters/”;
Diagram diagram = new Diagram();
diagram.addMaster(dataDir + “NetApp-FAS-series.vss”, “FAS80xx rear empty”);
Page srcPage = diagram.getPages().get(0);
srcPage.setBackPage(null);
long shapeID = diagram.addShape(0, 0, “FAS80xx rear empty”, 0);
Shape shape = srcPage.getShapes().getShape(shapeID);
shape.setWidth(2 * shape.getXForm().getWidth().getValue());
shape.setHeight(2 * shape.getXForm().getHeight().getValue());

	double shapeWidth = shape.getXForm().getWidth().getValue();
	double shapeHeight = shape.getXForm().getHeight().getValue();
	shape.move(shapeWidth * 0.5, shapeHeight * 0.5);
	
	srcPage.getPageSheet().getPageProps().getPageWidth().setValue(shapeWidth);
	srcPage.getPageSheet().getPageProps().getPageHeight().setValue(shapeHeight);
	
	System.out.println(dataDir);
	diagram.save(dataDir + "CreateMaster-out.vsdx", SaveFileFormat.VSDX);

}

@schapman2ca16,

We managed to replicate the problem of large size shape in our environment. It has been logged under the ticket ID DIAGRAMJAVA-50588 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Thanks for the quick reply. Will there be an update informing if you plan on making a fix for this problem?

Thanks again

@schapman2ca16,

The linked ticket ID DIAGRAMJAVA-50588 has just been identified. Our product team will investigate as per their development schedules. We will let you know once the significant progress has been made in this regard.

As a workaround, you can set the size of VIsio shape and page as per your requirement.
Java

// call a Diagram class constructor to load the VSDX diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get page by name
Page srcPage = diagram.getPages().getPage("Page-1");
// trim page size
srcPage.getPageSheet().getPageProps().getPageWidth().setValue(8.5);
srcPage.getPageSheet().getPageProps().getPageHeight().setValue(11.69);
// get shape by id
Shape shape = srcPage.getShapes().getShape(796);
shape.setWidth(shape.getXForm().getWidth().getValue()*0.3);
shape.setHeight(shape.getXForm().getHeight().getValue()*0.3);

@schapman2ca16,

The linked ticket ID DIAGRAMJAVA-50588 has been fixed and will be included in the next version 18.3 of Aspose.Diagram for Java API. We will notify you once it is published.

The issues you have found earlier (filed as DIAGRAMJAVA-50588) have been fixed in Aspose.Diagram for Java 18.3 API. This message was posted using BugNotificationTool from Downloads module by imran.rafique