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);
}