Last active
February 22, 2017 14:43
-
-
Save aspose-diagram/92a05cb833bad6d60de2968c96b40ee4 to your computer and use it in GitHub Desktop.
This Gist contains Java code snippets for examples of Aspose.Diagram for Java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddPageLevelCommentInVisio.class); | |
// Call the diagram constructor to load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Add comment | |
diagram.getPages().getPage(0).addComment(7.205905511811023, 3.880708661417323, "test@"); | |
// Save diagram | |
diagram.save(dataDir + "AddPageLevelCommentInVisio_Out.vdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(EditPageLevelCommentInVisio.class); | |
// load Visio | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get collection of the annotations | |
AnnotationCollection annotations = diagram.getPages().getPage("Page-1").getPageSheet().getAnnotations(); | |
// iterate through the annotations | |
for (Annotation annotation : (Iterable<Annotation>) annotations) | |
{ | |
String comment = annotation.getComment().getValue(); | |
comment += "Updation mark"; | |
annotation.getComment().setValue(comment); | |
} | |
// save Visio | |
diagram.save(dataDir + "EditPageLevelCommentInVisio_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AutoFitShapesInVisio.class); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "BFlowcht.vsdx"); | |
// use saving options | |
DiagramSaveOptions options = new DiagramSaveOptions(SaveFileFormat.VSDX); | |
// set Auto fit page property | |
options.setAutoFitPageToDrawingContent(true); | |
// save Visio diagram | |
diagram.save(dataDir + "AutoFitShapesInVisio_Out.vsdx", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateDiagram.class); | |
// Create directory if it is not already present. | |
File file = new File(dataDir); | |
if (!file.exists()) | |
file.mkdir(); | |
// initialize a new Diagram | |
Diagram diagram = new Diagram(); | |
// save in the VSDX format | |
diagram.save(dataDir + "CreateDiagram_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToSWFWithoutViewer.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToSWFWithoutViewer.vsd"); | |
SWFSaveOptions options = new SWFSaveOptions(); | |
options.setSaveFormat(SaveFileFormat.SWF); | |
// Exclude the embedded viewer | |
options.setViewerIncluded(false); | |
diagram.save(dataDir+ "ExportToSWFWithoutViewer_Out.swf", SaveFileFormat.SWF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(LayOutShapesInCompactTreeStyle.class); | |
String fileName = "LayOutShapesInCompactTreeStyle.vdx"; | |
// load an existing Visio diagram | |
Diagram diagram = new Diagram(dataDir + fileName); | |
// set layout options | |
LayoutOptions compactTreeOptions = new LayoutOptions(); | |
compactTreeOptions.setLayoutStyle(LayoutStyle.COMPACT_TREE); | |
compactTreeOptions.setEnlargePage(true); | |
// set layout direction as DownThenRight and then save | |
compactTreeOptions.setDirection(LayoutDirection.DOWN_THEN_RIGHT); | |
diagram.layout(compactTreeOptions); | |
diagram.save(dataDir + "sample_down_right.vdx", SaveFileFormat.VDX); | |
// set layout direction as DownThenLeft and then save | |
diagram = new Diagram(dataDir + fileName); | |
compactTreeOptions.setDirection(LayoutDirection.DOWN_THEN_LEFT); | |
diagram.layout(compactTreeOptions); | |
diagram.save(dataDir + "sample_down_left.vdx", SaveFileFormat.VDX); | |
// set layout direction as RightThenDown and then save | |
diagram = new Diagram(dataDir + fileName); | |
compactTreeOptions.setDirection(LayoutDirection.RIGHT_THEN_DOWN); | |
diagram.layout(compactTreeOptions); | |
diagram.save(dataDir + "sample_right_down.vdx", SaveFileFormat.VDX); | |
// set layout direction as LeftThenDown and then save | |
diagram = new Diagram(dataDir + fileName); | |
compactTreeOptions.setDirection(LayoutDirection.LEFT_THEN_DOWN); | |
diagram.layout(compactTreeOptions); | |
diagram.save(dataDir + "sample_left_down.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(LayOutShapesInFlowchartStyle.class); | |
// load an existing Visio diagram | |
String fileName = "LayOutShapesInFlowchartStyle.vdx"; | |
Diagram diagram = new Diagram(dataDir + fileName); | |
// set layout options | |
LayoutOptions flowChartOptions = new LayoutOptions(); | |
flowChartOptions.setLayoutStyle(LayoutStyle.FLOW_CHART); | |
flowChartOptions.setSpaceShapes(1f); | |
flowChartOptions.setEnlargePage(true); | |
// set layout direction as BottomToTop and then save | |
flowChartOptions.setDirection(LayoutDirection.BOTTOM_TO_TOP); | |
diagram.layout(flowChartOptions); | |
diagram.save(dataDir + "sample_btm_top.vdx", SaveFileFormat.VDX); | |
// set layout direction as TopToBottom and then save | |
diagram = new Diagram(dataDir + fileName); | |
flowChartOptions.setDirection(LayoutDirection.TOP_TO_BOTTOM); | |
diagram.layout(flowChartOptions); | |
diagram.save(dataDir + "sample_top_btm.vdx", SaveFileFormat.VDX); | |
// set layout direction as LeftToRight and then save | |
diagram = new Diagram(dataDir + fileName); | |
flowChartOptions.setDirection(LayoutDirection.LEFT_TO_RIGHT); | |
diagram.layout(flowChartOptions); | |
diagram.save(dataDir + "sample_left_right.vdx", SaveFileFormat.VDX); | |
// set layout direction as RightToLeft and then save | |
diagram = new Diagram(dataDir + fileName); | |
flowChartOptions.setDirection(LayoutDirection.RIGHT_TO_LEFT); | |
diagram.layout(flowChartOptions); | |
diagram.save(dataDir + "sample_right_left.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// load an existing Visio diagram | |
String dataDir = Utils.getDataDir(ModifyVBAModuleCode.class); | |
InputStream input = new FileInputStream(dataDir + "macro.vsdm"); | |
Diagram diagram = new Diagram(input); | |
// extract VBA project | |
VbaProject v = diagram.getVbaProject(); | |
// Iterate through the modules and modify VBA macro code | |
for (int i = 0; i < diagram.getVbaProject().getModules().getCount(); i++) { | |
VbaModule module = diagram.getVbaProject().getModules().get(i); | |
String code = module.getCodes(); | |
if (code.contains("This is test message.")) | |
code = code.replace("This is test message.", "This is Aspose.Diagram message."); | |
module.setCodes(code); | |
} | |
// save the Visio diagram | |
diagram.save(dataDir + "out.vssm", SaveFileFormat.VSSM); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadDiagramFile.class); | |
// Open the stream. Read only access is enough for Aspose.Diagram to load a diagram. | |
InputStream stream = new FileInputStream(dataDir + "ReadDiagramFile.vsdx"); | |
// load diagram | |
Diagram vsdDiagram = new Diagram(stream); | |
// get pages count | |
System.out.println("Total Pages:" + vsdDiagram.getPages().getCount()); | |
stream.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RemoveMacrosFromVisio.class); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// remove all macros | |
diagram.setVbProjectData(null); | |
// Save diagram | |
diagram.save(dataDir + "RemoveMacrosFromVisio_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveConnectorInfo.class); | |
//Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "RetrieveConnectorInfo.vsd"); | |
for(Connect connector : (Iterable<Connect>) diagram.getPages().getPage(0).getConnects()) | |
{ | |
// Display information about the Connectors | |
System.out.println("\nFrom Shape ID : " + connector.getFromSheet()); | |
System.out.println("To Shape ID : " + connector.getToSheet()); | |
} | |
System.out.println("Process Completed Successfully"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveFontInfo.class); | |
// call the diagram constructor to load diagram | |
Diagram diagram = new Diagram(dataDir+ "RetrieveFontInfo.vsd"); | |
for(Font font : (Iterable<Font>) diagram.getFonts()) | |
{ | |
// Display information about the fonts | |
System.out.println(font.getName()); | |
} | |
System.out.println("Process Completed Successfully"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SettingEventCells.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "TestTemplate.vsdm"); | |
// get page | |
Page page = diagram.getPages().get(0); | |
// get shape id | |
long shapeId = page.addShape(3.0, 3.0, 0.36, 0.36, "Square"); | |
// get shape | |
Shape shape = page.getShapes().getShape(shapeId); | |
// set event cells in the ShapeSheet | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
shape.getEvent().getEventXFMod().getUfe().setF("CALLTHIS(\"ThisDocument.ShowAlert\")"); | |
// save diagram | |
diagram.save(dataDir + "Output_NET.vsdm", SaveFileFormat.VSDM); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(EditDataConAndRefreshRecords.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsd"); | |
// set connecting string | |
diagram.getDataConnections().get(0).setConnectionString("Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=True"); | |
// set command | |
diagram.getDataConnections().get(0).setCommand("SELECT * from Project with(nolock)"); | |
// save Visio diagram | |
diagram.save(dataDir + "EditDataConAndRefreshRecords_Out.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SpecifyFontLocation.class); | |
String[] fontDirs = new String[] { "C:\\MyFonts\\", "D:\\Misc\\Fonts\\" }; | |
//Load the Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//setting the custom font directories | |
diagram.setFontDirs(fontDirs); | |
//saving Visio diagram in PDF format | |
diagram.save(dataDir + "SetFontsFolders_Out.pdf", SaveFileFormat.PDF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(EditConnectorGeometry.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//set connector shape id | |
long connectorId = 4; | |
Shape connector = diagram.getPages().getPage("Page-1").getShapes().getShape(connectorId); | |
//get connector geometry at index 0 | |
LineTo defaultLineTo = connector.getGeoms().get(0).getCoordinateCol().getLineToCol().get(0); | |
//remove connector geometry from index 0 | |
connector.getGeoms().get(0).getCoordinateCol().getLineToCol().get(0).setDel(BOOL.TRUE); | |
//initialize LineTo geometry object | |
LineTo lineTo = new LineTo(); | |
//set X value | |
lineTo.getX().setValue(0); | |
//set Y value | |
lineTo.getY().setValue(defaultLineTo.getY().getValue() / 2); | |
//add connector geometry | |
connector.getGeoms().get(0).getCoordinateCol().add(lineTo); | |
//initialize LineTo geometry object | |
lineTo = new LineTo(); | |
//set Y value | |
lineTo.getY().setValue(defaultLineTo.getY().getValue() / 2); | |
//set X value | |
lineTo.getX().setValue(defaultLineTo.getX().getValue()); | |
//add connector geometry | |
connector.getGeoms().get(0).getCoordinateCol().add(lineTo); | |
//initialize LineTo geometry object | |
lineTo = new LineTo(); | |
//set X value | |
lineTo.getX().setValue(defaultLineTo.getX().getValue()); | |
//set Y value | |
lineTo.getY().setValue(defaultLineTo.getY().getValue()); | |
//add connector geometry | |
connector.getGeoms().get(0).getCoordinateCol().add(lineTo); | |
//save diagram in VDX format | |
diagram.save(dataDir + "EditConnectorGeometry_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddHyperlinkToShape.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(2); | |
//initialize Hyperlink object | |
Hyperlink hyperlink = new Hyperlink(); | |
//set address value | |
hyperlink.getAddress().setValue("http://www.google.com/"); | |
//set sub address value | |
hyperlink.getSubAddress().setValue("Sub address here"); | |
//set description value | |
hyperlink.getDescription().setValue("Description here"); | |
//set name | |
hyperlink.setName("MyHyperLink"); | |
//add hyperlink to the shape | |
shape.getHyperlinks().add(hyperlink); | |
//save diagram to local space | |
diagram.save(dataDir + "AddHyperlinkToShape_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetHyperlinks.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// iterate through the hyperlinks | |
for (Hyperlink hyperlink :(Iterable<Hyperlink>) shape.getHyperlinks()) | |
{ | |
System.out.println("Address: " + hyperlink.getAddress().getValue()); | |
System.out.println("Sub Address: " + hyperlink.getSubAddress().getValue()); | |
System.out.println("Description: " + hyperlink.getDescription().getValue()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(DetectFormatfromInputStream.class); | |
// Open the stream. Read only access to load a Visio diagram. | |
String stream = new String(dataDir + "Drawing1.vsdx"); | |
// detect file format using an input stream | |
FileFormatInfo info = FileFormatUtil.detectFileFormat(stream); | |
// get the detected file format | |
System.out.println("The spreadsheet format is: " + info.getFileFormatType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(DetectVisioFileFormat.class); | |
// detect file format using the direct file path | |
FileFormatInfo info = FileFormatUtil.detectFileFormat(dataDir + "Drawing1.vsdx"); | |
// get the detected file format | |
System.out.println("The spreadsheet format is: " + info.getFileFormatType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetLibraryVersion.class); | |
// build path of an existing diagram | |
String path = dataDir + "Drawing1.vsdx"; | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(path); | |
//Display Visio version and document modification time at different stages | |
System.out.println("Visio Instance Version : " + diagram.getVersion()); | |
System.out.println("Full Build Number Created : " + diagram.getDocumentProps().getBuildNumberCreated()); | |
System.out.println("Full Build Number Edited : " + diagram.getDocumentProps().getBuildNumberEdited()); | |
System.out.println("Date Created : " + diagram.getDocumentProps().getTimeCreated()); | |
System.out.println("Date Last Edited : " + diagram.getDocumentProps().getTimeEdited()); | |
System.out.println("Date Last Printed : " + diagram.getDocumentProps().getTimePrinted()); | |
System.out.println("Date Last Saved : " + diagram.getDocumentProps().getTimeSaved()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetVisioProperties.class); | |
// build path of an existing diagram | |
String path = dataDir + "Drawing1.vsdx"; | |
//Call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(path); | |
//Set some summary information about the diagram | |
diagram.getDocumentProps().setCreator("Ijaz"); | |
diagram.getDocumentProps().setCompany("Aspose"); | |
diagram.getDocumentProps().setCategory("Drawing 2D"); | |
diagram.getDocumentProps().setManager("Sergey Polshkov"); | |
diagram.getDocumentProps().setTitle("Aspose Title"); | |
diagram.getDocumentProps().setTimeCreated(DateTime.getNow()); | |
diagram.getDocumentProps().setSubject("Visio Diagram"); | |
diagram.getDocumentProps().setTemplate("Aspose Template"); | |
//Write the updated file to the disk in VSDX file format | |
diagram.save(dataDir + "SetVisioProperties_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(AddLayer.class) + "Layers/"; | |
// load a source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get Visio page | |
Page page = diagram.getPages().getPage("Page-1"); | |
// initialize a new Layer class object | |
Layer layer = new Layer(); | |
// set Layer name | |
layer.getName().setValue("Layer1"); | |
// set Layer Visibility | |
layer.getVisible().setValue(BOOL.TRUE); | |
// set the color checkbox of Layer | |
layer.setColorChecked(BOOL.TRUE); | |
// add Layer to the particular page sheet | |
page.getPageSheet().getLayers().add(layer); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(3); | |
// assign shape to this new Layer | |
shape.getLayerMem().getLayerMember().setValue(Integer.toString(layer.getIX())); | |
// save diagram | |
diagram.save(dataDir + "AddLayer_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ConfigureShapeLayers.class); | |
//call the diagram constructor to load visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// iterate through the shapes | |
for (Shape shape : (Iterable<Shape>) diagram.getPages().getPage("Page-1").getShapes()) | |
{ | |
if (shape.getName().toLowerCase() == "shape1") | |
{ | |
//Add shape1 in first two layers. Here "0;1" are indexes of the layers | |
LayerMem layer = shape.getLayerMem(); | |
layer.getLayerMember().setValue("0;1"); | |
} | |
else if (shape.getName().toLowerCase() == "shape2") | |
{ | |
//Remove shape2 from all the layers | |
LayerMem layer = shape.getLayerMem(); | |
layer.getLayerMember().setValue(""); | |
} | |
else if (shape.getName().toLowerCase() == "shape3") | |
{ | |
//Add shape3 in first layer. Here "0" is index of the first layer | |
LayerMem layer = shape.getLayerMem(); | |
layer.getLayerMember().setValue("0"); | |
} | |
} | |
// save diagram | |
diagram.save(dataDir + "ConfigureShapeLayers_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveAllLayers.class); | |
// load Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get Visio page | |
Page page = diagram.getPages().getPage("Page-1"); | |
// iterate through the layers | |
for (Layer layer : (Iterable<Layer>) page.getPageSheet().getLayers()) | |
{ | |
System.out.println("Name: " + layer.getName().getValue()); | |
System.out.println("Visibility: " + layer.getVisible().getValue()); | |
System.out.println("Status: " + layer.getStatus().getValue()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// set path of the license file, i.e. c:\temp\ | |
String dataDir = "c:\\temp\\"; | |
License license = new License(); | |
license.setLicense(dataDir + "Aspose.Diagram.lic"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// set path of the license file, i.e. c:\temp\ | |
String dataDir = "c:\\temp\\"; | |
// load an existing Visio file in the stream | |
InputStream licStream = new FileInputStream(dataDir + "Aspose.Diagram.lic"); | |
License license = new License(); | |
// apply license | |
license.setLicense(licStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// Initialize a Metered license class object | |
Metered metered = new Metered(); | |
// apply public and private keys | |
metered.setMeteredKey("your-public-key", "your-private-key"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(ConvertVisioWithSelectiveShapes.class) + "LoadSaveConvert\\"; | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// create an instance SVG save options class | |
SVGSaveOptions options = new SVGSaveOptions(); | |
ShapeCollection shapes = options.getShapes(); | |
// get shapes by page index and shape ID, and then add in the shape collection object | |
shapes.add(diagram.getPages().get(0).getShapes().getShape(1)); | |
shapes.add(diagram.getPages().get(0).getShapes().getShape(2)); | |
// save Visio drawing | |
diagram.save(dataDir + "SelectiveShapes_out.svg", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateNewVisio.class); | |
// initialize a Diagram class | |
Diagram diagram = new Diagram(); | |
// save diagram in the VSDX format | |
diagram.save(dataDir + "CreateNewVisio_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportHTMLinStream.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "ExportToHTML.vsd"); | |
// save resultant HTML directly to a stream | |
ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); | |
diagram.save(dstStream, SaveFileFormat.HTML); | |
// In you want to read the result into a Diagram object again, in Java you need to get the | |
// data bytes and wrap into an input stream. | |
ByteArrayInputStream srcStream = new ByteArrayInputStream(dstStream.toByteArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportPageToImage.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "ExportPageToImage.vsd"); | |
//Save diagram as PNG | |
ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.PNG); | |
// Save one page only, by page index | |
options.setPageIndex(0); | |
//Save resultant Image file | |
diagram.save(dataDir + "ExportPageToImage_Out.png", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToHTML.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToHTML.vsd"); | |
// Save as HTML | |
diagram.save(dataDir + "ExportToHTML_Out.html", SaveFileFormat.HTML); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToImage.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToImage.vsd"); | |
// Save as PNG | |
diagram.save(dataDir+ "ExportToImage_Out.png", SaveFileFormat.PNG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToPDF.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToPDF.vsd"); | |
// Save as PDF file format | |
diagram.save(dataDir + "ExportToPDF_Out.pdf", SaveFileFormat.PDF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToSVG.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToSVG.vsd"); | |
// Save as SVG | |
diagram.save(dataDir+ "ExportToSVG_Out.svg", SaveFileFormat.SVG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToSWF.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToSWF.vsd"); | |
// save as SWF | |
diagram.save(dataDir + "ExportToSWF_Out.swf", SaveFileFormat.SWF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToXAML.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToXAML.vsd"); | |
// save as XAML | |
diagram.save(dataDir + "ExportToXAML_Out.xaml", SaveFileFormat.XAML); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToXML.class); | |
/* 1. Exporting VSDX to VDX */ | |
//Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "ExportToXML.vsd"); | |
//Save input VSD as VDX | |
diagram.save(dataDir + "ExportToXML_Out.vdx", SaveFileFormat.VDX); | |
/* 2. Exporting from VSD to VSX */ | |
// Call the diagram constructor to load diagram from a VSD file | |
//Save input VSD as VSX | |
diagram.save(dataDir + "ExportToXML_Out.vsx", SaveFileFormat.VSX); | |
/* 3. Export VSD to VTX */ | |
//Save input VSD as VTX | |
diagram.save(dataDir + "ExportToXML_Out.vtx", SaveFileFormat.VTX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportToXPS.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir+ "ExportToXPS.vsd"); | |
// Save as XPS | |
diagram.save(dataDir + "ExportToXPS_Out.xps", SaveFileFormat.XPS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadVisioDiagram.class); | |
// Open the stream. Read only access is enough for Aspose.Diagram to load a diagram. | |
InputStream stream = new FileInputStream(dataDir + "Drawing1.vsdx"); | |
//Call the diagram constructor to load diagram from a VSDX stream | |
Diagram vsdDiagram = new Diagram(stream); | |
stream.close(); | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx"); | |
/* | |
* Call diagram constructor to load diagram from a VSS file | |
* providing load file format | |
*/ | |
Diagram vssDiagram = new Diagram(dataDir + "Basic.vss", LoadFileFormat.VSS); | |
/* | |
* Call diagram constructor to load diagram from a VSX file | |
* providing load options | |
*/ | |
LoadOptions loadOptions = new LoadOptions(LoadFileFormat.VSX); | |
Diagram vsxDiagram = new Diagram(dataDir + "Drawing1.vsx", loadOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SaveVisioDiagram.class); | |
// load an existing Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// save diagram using the direct path | |
diagram.save(dataDir + "SaveVisioDiagram_Out.vsdx", SaveFileFormat.VSDX); | |
ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); | |
// save diagram in the stream | |
diagram.save(dstStream, SaveFileFormat.VSDX); | |
// In you want to read the result into a Diagram object again, in Java you need to get the | |
// data bytes and wrap into an input stream. | |
ByteArrayInputStream srcStream = new ByteArrayInputStream(dstStream.toByteArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseDiagramSaveOptions.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Options when saving a diagram into Visio format | |
DiagramSaveOptions options = new DiagramSaveOptions(SaveFileFormat.VSDX); | |
// Summary: | |
/*When characters in the diagram are unicode and not be set with correct font | |
value or the font is not installed locally, they may appear as block in pdf, | |
image or XPS. Set the DefaultFont such as MingLiu or MS Gothic to show these | |
characters.*/ | |
options.setDefaultFont("MS Gothic"); | |
// Summary: | |
// Defines whether need enlarge page to fit drawing content or not. | |
// Remarks: | |
// Default value is false. | |
options.setAutoFitPageToDrawingContent(true); | |
// save diagram | |
diagram.save(dataDir + "UseDiagramSaveOptions_Out.vsdx", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseHTMLSaveOptions.class); | |
// call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Options when saving a diagram into the HTML format | |
HTMLSaveOptions options = new HTMLSaveOptions(); | |
// Summary: | |
// value or the font is not installed locally, they may appear as a block, | |
// set the DefaultFont such as MingLiu or MS Gothic to show these | |
// characters. | |
options.setDefaultFont("MS Gothic"); | |
// sets the number of pages to render in HTML. | |
options.setPageCount(2); | |
// sets the 0-based index of the first page to render. Default is 0. | |
options.setPageIndex(0); | |
// set page size | |
PageSize pgSize = new PageSize(PaperSizeFormat.A_1); | |
options.setPageSize(pgSize); | |
// discard saving background pages of the Visio diagram | |
options.setSaveForegroundPagesOnly(true); | |
// specify whether to include the toolbar or not. Default value is true. | |
options.setSaveToolBar(false); | |
// set title of the HTML document | |
options.setTitle("Title goes here"); | |
// save in any supported file format | |
diagram.save(dataDir + "UseHTMLSaveOptions_Out.html", options); | |
// save resultant HTML directly to a stream | |
ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); | |
diagram.save(dstStream, SaveFileFormat.HTML); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseImageSaveOptions.class); | |
// Call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.JPEG); | |
// specify the quality level to use during compositing. | |
options.setCompositingQuality(CompositingQuality.HIGH_QUALITY); | |
// sets the brightness for the the generated images. | |
// this property has effect only when saving to raster image formats. | |
//The default value is 0.5. The value must be in the range between 0 and 1. | |
options.setImageBrightness(1f); | |
// Summary: | |
// value or the font is not installed locally, they may appear as a block, | |
// set the DefaultFont such as MingLiu or MS Gothic to show these | |
// characters. | |
options.setDefaultFont("MS Gothic"); | |
// sets the number of pages to render in image. | |
options.setPageCount(2); | |
// sets the 0-based index of the first page to render. Default is 0. | |
options.setPageIndex(0); | |
// set page size | |
PageSize pgSize = new PageSize(PaperSizeFormat.A_1); | |
options.setPageSize(pgSize); | |
// discard saving background pages of the Visio diagram | |
options.setSaveForegroundPagesOnly(true); | |
// sets the color mode for the generated images. | |
options.setImageColorMode(ImageColorMode.BLACK_AND_WHITE); | |
// sets the contrast for the generated images. | |
// this property has effect only when saving to raster image formats. | |
// the default value is 0.5. The value must be in the range between 0 and 1. | |
options.setImageContrast(1f); | |
// specify the algorithm that is used when images are scaled or rotated. | |
// this property has effect only when saving to raster image formats. | |
options.setInterpolationMode(InterpolationMode.NEAREST_NEIGHBOR); | |
// the value may vary from 0 to 100 where 0 means worst quality, | |
// but maximum compression and 100 means best quality but minimum compression. | |
// the default value is 95. | |
options.setJpegQuality(100); | |
// set a value specifying how pixels are offset during rendering. | |
options.setPixelOffsetMode(PixelOffsetMode.HIGH_SPEED); | |
// sets the resolution for the generated images, in dots per inch. The default value is 96. | |
options.setResolution(2f); | |
// sets the zoom factor for the generated images. | |
// the default value is 1.0. The value must be greater than 0. | |
options.setScale(1f); | |
// specify whether smoothing (antialiasing) is applied to lines | |
// and curves and the edges of filled areas. | |
options.setSmoothingMode(SmoothingMode.HIGH_QUALITY); | |
// sets the type of compression to apply when saving generated images to the TIFF format. | |
options.setTiffCompression(TiffCompression.CCITT_3); | |
// save in any supported file format | |
diagram.save(dataDir + "UseImageSaveOptions_Out.jpeg", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UsePDFSaveOptions.class); | |
// call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Options when saving a diagram into the PDF format | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// discard saving background pages of the Visio diagram | |
options.setSaveForegroundPagesOnly(true); | |
// specify the quality of JPEG compression for images (if JPEG compression is used). Default is 95. | |
options.setJpegQuality(100); | |
// specify default font name | |
options.setDefaultFont("Arial"); | |
// conformance level for generated PDF document. | |
options.setCompliance(PdfCompliance.PDF_15); | |
// Load the certificate from disk. | |
// The other constructor overloads can be used to load certificates from different locations. | |
X509Certificate2 cert = new X509Certificate2(); //"c:\\temp\\certificate.pfx", "feyb4lgcfbme"); | |
// sets a digital signature details. If not set, then no signing will be performed. | |
options.setDigitalSignatureDetails(new PdfDigitalSignatureDetails(cert, "Test Signing", "Aspose Office", DateTime.getNow(), PdfDigitalSignatureHashAlgorithm.SHA_256)); | |
// set encription details | |
PdfEncryptionDetails encriptionDetails = new PdfEncryptionDetails("user password", "Owner Password", PdfEncryptionAlgorithm.RC_4_128); | |
options.setEncryptionDetails(encriptionDetails); | |
// sets the number of pages to render in PDF. | |
options.setPageCount(2); | |
// sets the 0-based index of the first page to render. Default is 0. | |
options.setPageIndex(0); | |
// set page size | |
PageSize pgSize = new PageSize(PaperSizeFormat.A_1); | |
options.setPageSize(pgSize); | |
// save in any supported file format | |
diagram.save(dataDir + "UsePDFSaveOptions_Out.pdf", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseSVGSaveOptions.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
SVGSaveOptions options = new SVGSaveOptions(); | |
// Summary: | |
// value or the font is not installed locally, they may appear as a block, | |
// set the DefaultFont such as MingLiu or MS Gothic to show these | |
// characters. | |
options.setDefaultFont("MS Gothic"); | |
// sets the 0-based index of the first page to render. Default is 0. | |
options.setPageIndex(0); | |
// set page size | |
PageSize pgSize = new PageSize(PaperSizeFormat.A_1); | |
options.setPageSize(pgSize); | |
diagram.save(dataDir + "UseSVGSaveOptions_Out.svg", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseSWFSaveOptions.class); | |
// call the diagram constructor to load diagram from a VSD file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
SWFSaveOptions options = new SWFSaveOptions(); | |
// Summary: | |
// value or the font is not installed locally, they may appear as a block, | |
// set the DefaultFont such as MingLiu or MS Gothic to show these | |
// characters. | |
options.setDefaultFont("MS Gothic"); | |
// sets the number of pages to render in SWF. | |
options.setPageCount(2); | |
// sets the 0-based index of the first page to render. Default is 0. | |
options.setPageIndex(0); | |
// discard saving background pages of the Visio diagram | |
options.setSaveForegroundPagesOnly(true); | |
// specify whether the generated SWF document should include the integrated document viewer or not. | |
options.setViewerIncluded(true); | |
// save diagram | |
diagram.save(dataDir + "UseSWFSaveOptions_Out.swf", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddMasterFromStencil.class); | |
// Load diagram | |
Diagram diagram = new Diagram(); | |
// Load stencil to a stream | |
String templateFileName = dataDir + "NetApp-FAS-series.vss"; | |
// Add master with stencil file path and master id | |
String masterName = "FAS80xx rear empty"; | |
diagram.addMaster(templateFileName, 2); | |
// Add master with stencil file path and master name | |
diagram.addMaster(templateFileName, masterName); | |
// adds master to diagram from source diagram | |
Diagram src = new Diagram(templateFileName); | |
diagram.addMaster(src, masterName); | |
// Adds shape with defined PinX and PinY. | |
diagram.addShape(2.0, 2.0, masterName, 0); | |
diagram.addShape(6.0, 6.0, masterName, 0); | |
// Adds shape with defined PinX,PinY,Width and Height. | |
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
private final static char map[] = { // 0 1 2 3 4 5 6 7 | |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 | |
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 1 | |
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 2 | |
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 3 | |
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 4 | |
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 5 | |
'w', 'x', 'y', 'z', '0', '1', '2', '3', // 6 | |
'4', '5', '6', '7', '8', '9', '+', '/' // 7 | |
}; | |
private final String lineSeparator; | |
private final boolean splitLines; | |
public BASE64Encoder() { | |
lineSeparator = System.getProperty("line.separator"); | |
splitLines = true; | |
} | |
final void encodeBuffer(final InputStream inStream, final Writer outStream) throws IOException { | |
final byte[] tmpbuffer = new byte[57]; | |
while (true) { | |
final int numBytes = readFully(inStream, tmpbuffer); | |
if (numBytes == -1) { | |
break; | |
} | |
for (int j = 0; j < numBytes; j += 3) { | |
if ((j + 3) <= numBytes) { | |
encodeAtom(outStream, tmpbuffer, j, 3); | |
} else { | |
encodeAtom(outStream, tmpbuffer, j, (numBytes) - j); | |
} | |
} | |
if (splitLines) { | |
outStream.write(lineSeparator); | |
} | |
if (numBytes < 57) { | |
break; | |
} | |
} | |
} | |
public final String encodeBuffer(final byte[] aBuffer) { | |
final StringWriter outStream = new StringWriter();// aBuffer.length + | |
// aBuffer.length>>1); | |
try { | |
encodeBuffer(new ByteArrayInputStream(aBuffer), outStream); | |
} catch (final IOException e) { | |
e.printStackTrace(); | |
} | |
return outStream.toString(); | |
} | |
final void encodeAtom(final Writer outStream, final byte[] data, final int offset, final int len) throws IOException { | |
final byte a; | |
final byte b; | |
final byte c; | |
if (len == 1) { | |
a = data[offset]; | |
b = 0; | |
c = 0; | |
outStream.write(map[(a >>> 2) & 0x3F]); | |
outStream.write(map[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); | |
outStream.write('='); | |
outStream.write('='); | |
} else if (len == 2) { | |
a = data[offset]; | |
b = data[offset + 1]; | |
c = 0; | |
outStream.write(map[(a >>> 2) & 0x3F]); | |
outStream.write(map[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); | |
outStream.write(map[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); | |
outStream.write('='); | |
} else { | |
a = data[offset]; | |
b = data[offset + 1]; | |
c = data[offset + 2]; | |
outStream.write(map[(a >>> 2) & 0x3F]); | |
outStream.write(map[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); | |
outStream.write(map[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); | |
outStream.write(map[c & 0x3F]); | |
} | |
} | |
private final int readFully(final InputStream in, final byte[] buffer) throws IOException { | |
final int len = buffer.length; | |
for (int i = 0; i < len; i++) { | |
final int q = in.read(); | |
if (q == -1) { | |
return i; | |
} | |
buffer[i] = (byte) q; | |
} | |
return len; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CheckMasterPresencebyID.class); | |
// Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "Basic Shapes.vss"); | |
// set master id | |
int masterid = 2; | |
// check master by id | |
boolean isPresent = diagram.getMasters().isExist(2); | |
System.out.println("Master Presence : " + isPresent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CheckMasterPresencebyName.class); | |
// Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "Basic Shapes.vss"); | |
// Set master name | |
String masterName = "VNXe3100 Storage Processor Rear"; | |
// check master object by name | |
boolean isPresent = diagram.getMasters().isExist(masterName); | |
System.out.println("Master Presence : " + isPresent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(CreateMasterfromScratch.class) + "Masters/"; | |
// create a new template | |
Diagram diagram = new Diagram(); | |
// add master | |
diagram.getMasters().add(createMaster(101, "Regular", new ImageIcon(dataDir + "icon.png").getImage())); | |
// save template | |
diagram.save(dataDir + "template_Out.vtx", SaveFileFormat.VTX); | |
} | |
// create master | |
public static Master createMaster(final int masterId, final String name, final java.awt.Image image) throws Exception { | |
// set master properties | |
Master ms = new Master(); | |
ms.setID(masterId); | |
ms.setName(name); | |
ms.setIconSize(1); | |
ms.setAlignName(2); | |
ms.setMatchByName(0); | |
ms.setIconUpdate(1); | |
ms.setUniqueID(new g("00000000-0000-0000-0000-100000000" + masterId)); | |
ms.setUniqueID(new g("00000000-0000-0000-0000-100000000" + masterId)); | |
ms.setPatternFlags(0); | |
ms.setHidden(0); | |
// set master's shape properties | |
final Shape shape = new Shape(); | |
ms.getShapes().add(shape); | |
final String encodedImage = loadImage(image); | |
final double width = 0.5443889263424177; | |
final double height = 0.432916947568133; | |
shape.setID(5); | |
shape.setType(TypeValue.FOREIGN); | |
shape.getXForm().getPinX().setValue(0.2221944631712089); | |
shape.getXForm().getPinY().setValue(0.1666458473784065); | |
shape.getXForm().getWidth().setValue(width); | |
shape.getXForm().getHeight().setValue(height); | |
shape.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
shape.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
shape.getXForm().getResizeMode().setValue(0); | |
shape.getTextXForm().getTxtPinY().getUfe().setF("-TxtHeight/2"); | |
shape.getTextXForm().getTxtWidth().getUfe().setF("TEXTWIDTH(TheText)"); | |
shape.getTextXForm().getTxtHeight().getUfe().setF("TEXTHEIGHT(TheText, TxtWidth)"); | |
// set connection properties | |
final Connection connection = new Connection(); | |
shape.getConnections().add(connection); | |
connection.setID(1); | |
connection.setNameU("All"); | |
connection.getX().setValue(0.22); | |
connection.getX().getUfe().setF("Width*0.5"); | |
connection.getY().setValue(0.16); | |
connection.getY().getUfe().setF("Height*0.5"); | |
connection.getDirX().setValue(0); | |
connection.getDirY().setValue(0); | |
connection.getType().setValue(0); | |
connection.getAutoGen().setValue(BOOL.FALSE); | |
connection.getPrompt().getUfe().setF("No Formula"); | |
shape.getForeignData().setForeignType(ForeignType.BITMAP); | |
shape.getForeignData().setCompressionType(CompressionType.PNG); | |
shape.getForeignData().setValue(encodedImage.getBytes()); | |
return ms; | |
} | |
private static String loadImage(final java.awt.Image image) { | |
String imageDataString = ""; | |
try { | |
// Label als ImageObserver | |
final ImageObserver dummyObserver = new Label(); | |
final int width = image.getWidth(dummyObserver); | |
final int height = image.getHeight(dummyObserver); | |
// create new Image | |
final BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | |
// draw Image to BufferedImage | |
bImage.getGraphics().drawImage(image, 0, 0, dummyObserver); | |
final ByteArrayOutputStream os = new ByteArrayOutputStream(); | |
ImageIO.write(bImage, "png", os); | |
final byte[] imageData = os.toByteArray(); | |
final BASE64Encoder encoder = new BASE64Encoder(); | |
imageDataString = encoder.encodeBuffer(imageData); | |
} catch (final IOException ioe) { | |
System.out.println("Exception while reading the Image " + ioe); | |
} | |
return imageDataString; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetMasterbyID.class); | |
// Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "RetrieveMasterInfo.vdx"); | |
// Set master id | |
int masterid = 2; | |
// Get master object by id | |
Master master = diagram.getMasters().getMaster(masterid); | |
System.out.println("Master ID : " + master.getID()); | |
System.out.println("Master Name : " + master.getName()); | |
System.out.println("Master Name : " + master.getUniqueID()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetMasterbyName.class); | |
// Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "Basic Shapes.vss"); | |
// Set master name | |
String masterName = "Circle"; | |
// Get master object by name | |
Master master = diagram.getMasters().getMasterByName(masterName); | |
System.out.println("Master ID : " + master.getID()); | |
System.out.println("Master Name : " + master.getName()); | |
System.out.println("Master Name : " + master.getUniqueID()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveMasterInfo.class); | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "drawing.vdx"); | |
for (Master master : (Iterable<Master>) diagram.getMasters()) | |
{ | |
//Display information about the masters | |
System.out.println("\nMaster ID : " + master.getID()); | |
System.out.println("Master Name : " + master.getName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
String dataDir = Utils.getDataDir(ManipulateEmbeddedOLEObjects.class); | |
System.out.println(dataDir); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page of the Visio diagram by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape of the Visio diagram by ID | |
Shape OLE_Shape = page.getShapes().getShape(2); | |
// filter shapes by type Foreign | |
if (OLE_Shape.getType() == TypeValue.FOREIGN) { | |
if (OLE_Shape.getForeignData().getForeignType() == ForeignType.OBJECT) { | |
ByteArrayInputStream Ole_stream = new ByteArrayInputStream(OLE_Shape.getForeignData().getObjectData()); | |
// get format of the OLE file object | |
com.aspose.words.FileFormatInfo info = com.aspose.words.FileFormatUtil.detectFileFormat(Ole_stream); | |
if (info.getLoadFormat() == com.aspose.words.LoadFormat.DOC | |
|| info.getLoadFormat() == com.aspose.words.LoadFormat.DOCX) { | |
// modify an OLE object using Aspose.Words API | |
Document doc = new Document(new ByteArrayInputStream(OLE_Shape.getForeignData().getObjectData())); | |
doc.getRange().replace("testing", "Aspose", false, true); | |
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); | |
doc.save(outStream, com.aspose.words.SaveFormat.DOCX); | |
// replace an OLE object | |
OLE_Shape.getForeignData().setObjectData(outStream.toByteArray()); | |
} | |
} | |
} | |
// save Visio diagram | |
diagram.save(dataDir + "modified.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CopyVisioPage.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram originalDiagram = new Diagram(dataDir + "Drawing1.vsd"); | |
// initialize the new visio diagram | |
Diagram newDiagram = new Diagram(); | |
// add all masters from the source Visio diagram | |
MasterCollection originalMasters = originalDiagram.getMasters(); | |
for (Master master : (Iterable<Master>) originalMasters) { | |
newDiagram.addMaster(originalDiagram, master.getName()); | |
} | |
// get the page object from the original diagram | |
Page SrcPage = originalDiagram.getPages().getPage("Page-1"); | |
// set page name | |
SrcPage.setName("new page"); | |
// it calculates max page id | |
int max = 0; | |
if (newDiagram.getPages().getCount() != 0) | |
max = newDiagram.getPages().get(0).getID(); | |
for (int i = 1; i < newDiagram.getPages().getCount(); i++) | |
{ | |
if (max < newDiagram.getPages().get(i).getID()) | |
max = newDiagram.getPages().get(i).getID(); | |
} | |
int MaxPageId = max; | |
// set page id | |
SrcPage.setID(MaxPageId); | |
// add reference of the original diagram page | |
newDiagram.getPages().add(SrcPage); | |
// remove first empty page | |
newDiagram.getPages().remove(newDiagram.getPages().get(0)); | |
// save diagram in VDX format | |
newDiagram.save(dataDir + "CopyVisioPage_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetVisioPagebyID.class); | |
// Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Set page id | |
int pageid = 2; | |
// Get page object by id | |
Page page2 = diagram.getPages().getPage(pageid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetVisioPagebyName.class); | |
// Call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Set page name | |
String pageName = "Flow 2"; | |
// Get page object by name | |
Page page2 = diagram.getPages().getPage(pageName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(InsertBlankPageInVisio.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// it calculates max page id | |
int max = 0; | |
if (diagram.getPages().getCount() != 0) | |
max = diagram.getPages().get(0).getID(); | |
for (int i = 1; i < diagram.getPages().getCount(); i++) | |
{ | |
if (max < diagram.getPages().get(i).getID()) | |
max = diagram.getPages().get(i).getID(); | |
} | |
// Initialize a new page object | |
Page newPage = new Page(); | |
// Set name | |
newPage.setName("new page"); | |
// Set page ID | |
newPage.setID(max + 1); | |
// Or try the Page constructor | |
// Page newPage = new Page(MaxPageId + 1); | |
// Add a new blank page | |
diagram.getPages().add(newPage); | |
// Save diagram | |
diagram.save(dataDir + "InsertBlankPageInVisio_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrievePageInfo.class); | |
//Call the diagram constructor to load diagram | |
Diagram diagram = new Diagram(dataDir+ "RetrievePageInfo.vdx"); | |
for (Page page : (Iterable<Page>) diagram.getPages()) | |
{ | |
//Checks if current page is a background page | |
if (page.getBackground() == com.aspose.diagram.BOOL.TRUE) | |
{ | |
//Display information about the background page | |
System.out.println("Background Page ID : " + page.getID()); | |
System.out.println("Background Page Name : " + page.getName()); | |
} | |
else | |
{ | |
//Display information about the foreground page | |
System.out.println("\nPage ID : " + page.getID()); | |
System.out.println("Universal Name : " + page.getNameU()); | |
System.out.println("ID of the Background Page : " + page.getBackPage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetVisioPageOrientation.class); | |
// initialize the new visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get Visio page | |
Page page = diagram.getPages().getPage("Flow 1"); | |
// page orientation | |
page.getPageSheet().getPrintProps().getPrintPageOrientation().setValue(PrintPageOrientationValue.LANDSCAPE); | |
// save Visio | |
diagram.save(dataDir + "SetPageOrientation_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(BySpecificPrinter.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// call the print method to print whole Diagram using the printer name | |
diagram.print("LaserJet1100"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetPrintJobAndPrinterName.class); | |
// load a source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// call the print method to print whole Diagram using the printer name and set document name in the print job | |
diagram.print("LaserJet1100", "Job name while printing with Aspose.Diagram"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(VisioDiagramProtection.class); | |
//Load diagram | |
Diagram diagram = new Diagram(dataDir + "ProtectAndUnprotect.vsd"); | |
diagram.getDocumentSettings().setProtectBkgnds(BOOL.TRUE); | |
diagram.getDocumentSettings().setProtectMasters(BOOL.TRUE); | |
diagram.getDocumentSettings().setProtectShapes(BOOL.TRUE); | |
diagram.getDocumentSettings().setProtectStyles(BOOL.TRUE); | |
// save diagram | |
diagram.save(dataDir + "VisioDiagramProtection_Out.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(VisioShapeProtection.class); | |
//Load diagram | |
Diagram diagram = new Diagram(dataDir + "ProtectAndUnprotect.vsd"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Flow 1"); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// set protections | |
shape.getProtection().getLockAspect().setValue(BOOL.TRUE); | |
shape.getProtection().getLockBegin().setValue(BOOL.TRUE); | |
shape.getProtection().getLockCalcWH().setValue(BOOL.TRUE); | |
shape.getProtection().getLockCrop().setValue(BOOL.TRUE); | |
shape.getProtection().getLockCustProp().setValue(BOOL.TRUE); | |
shape.getProtection().getLockDelete().setValue(BOOL.TRUE); | |
shape.getProtection().getLockEnd().setValue(BOOL.TRUE); | |
shape.getProtection().getLockFormat().setValue(BOOL.TRUE); | |
shape.getProtection().getLockFromGroupFormat().setValue(BOOL.TRUE); | |
shape.getProtection().getLockGroup().setValue(BOOL.TRUE); | |
shape.getProtection().getLockHeight().setValue(BOOL.TRUE); | |
shape.getProtection().getLockMoveX().setValue(BOOL.TRUE); | |
shape.getProtection().getLockMoveY().setValue(BOOL.TRUE); | |
shape.getProtection().getLockRotate().setValue(BOOL.TRUE); | |
shape.getProtection().getLockSelect().setValue(BOOL.TRUE); | |
shape.getProtection().getLockTextEdit().setValue(BOOL.TRUE); | |
shape.getProtection().getLockThemeColors().setValue(BOOL.TRUE); | |
shape.getProtection().getLockThemeEffects().setValue(BOOL.TRUE); | |
shape.getProtection().getLockVtxEdit().setValue(BOOL.TRUE); | |
shape.getProtection().getLockWidth().setValue(BOOL.TRUE); | |
// save diagram | |
diagram.save(dataDir + "VisioShapeProtection_Out.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(ModifyShapeGradientFill.class) + "ShapeGradientFill\\"; | |
// load a Visio drawing | |
Diagram diagram = new Diagram(dataDir + "ShapewithGradientFill.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// get the gradient fill properties | |
GradientFill gradientfill = shape.getFill().getGradientFill(); | |
// get the gradient stops | |
GradientStopCollection stops = gradientfill.getGradientStops(); | |
// get the gradient stop by index | |
GradientStop stop = stops.get(0); | |
// set gradient stop properties | |
stop.getColor().getUfe().setF(""); | |
stop.getPosition().setValue(0.5); | |
gradientfill.getGradientDir().setValue(GradientFillDir.RECTANGLE_FROM_BOTTOM_RIGHT); | |
gradientfill.getGradientAngle().setValue(0.7853981633974501); | |
// save the Visio drawing | |
diagram.save(dataDir + "ShapewithGradientFill_out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddingNewShape.class); | |
//Load a diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-2"); | |
// Add master with stencil file path and master id | |
String masterName = "Rectangle"; | |
// Add master with stencil file path and master name | |
diagram.addMaster(dataDir + "Basic Shapes.vss", masterName); | |
// page indexing starts from 0 | |
int PageIndex = 1; | |
double width = 2, height = 2, pinX = 4.25, pinY = 4.5; | |
//Add a new rectangle shape | |
long rectangleId = diagram.addShape(pinX, pinY, width, height, masterName, PageIndex); | |
// set shape properties | |
Shape rectangle = page.getShapes().getShape(rectangleId); | |
rectangle.getXForm().getPinX().setValue(5); | |
rectangle.getXForm().getPinY().setValue(5); | |
rectangle.setType(TypeValue.SHAPE); | |
rectangle.getText().getValue().add(new Txt("Aspose Diagram")); | |
rectangle.setTextStyle(diagram.getStyleSheets().get(3)); | |
rectangle.getLine().getLineColor().setValue("#ff0000"); | |
rectangle.getLine().getLineWeight().setValue(0.03); | |
rectangle.getLine().getRounding().setValue(0.1); | |
rectangle.getFill().getFillBkgnd().setValue("#ff00ff"); | |
rectangle.getFill().getFillForegnd().setValue("#ebf8df"); | |
diagram.save(dataDir + "AddShape_Out.vsdx", SaveFileFormat.VSDX); | |
System.out.println("Shape has been added."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CalculateCenterOfSubShapes.class); | |
// load Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get group shape | |
Shape shape = diagram.getPages().get(0).getShapes().getShape(138); | |
// get sub-shape of the group shape | |
Shape subShape = shape.getShapes().getShape(140); | |
AffineTransform m = new AffineTransform(); | |
// apply the translation vector | |
m.translate(-(float)subShape.getXForm().getLocPinX().getValue(), -(float)subShape.getXForm().getLocPinY().getValue()); | |
// set the elements of that matrix to a rotation | |
m.rotate((float)subShape.getXForm().getAngle().getValue()); | |
// apply the translation vector | |
m.translate((float)subShape.getXForm().getPinX().getValue(), (float)subShape.getXForm().getPinY().getValue()); | |
// get pinx and piny | |
double pinx = m.getTranslateX(); | |
double piny = m.getTranslateY(); | |
// calculate the sub-shape pinx and piny | |
double resultx = shape.getXForm().getPinX().getValue() - shape.getXForm().getLocPinX().getValue() - pinx; | |
double resulty = shape.getXForm().getPinY().getValue() - shape.getXForm().getLocPinY().getValue() - piny; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ChangeShapeSize.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by id | |
Shape shape = page.getShapes().getShape(796); | |
// alter the size of Shape | |
shape.setWidth(2 * shape.getXForm().getWidth().getValue()); | |
shape.setHeight(2 * shape.getXForm().getHeight().getValue()); | |
// save diagram | |
diagram.save(dataDir + "ChangeShapeSize_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ConnectVisioSubShapes.class); | |
// set sub shape ids | |
long shapeFromId = 2; | |
long shapeToId = 4; | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// access a particular page | |
Page page = diagram.getPages().getPage("Page-3"); | |
// initialize connector shape | |
Shape shape = new Shape(); | |
shape.getLine().getEndArrow().setValue(4); | |
shape.getLine().getLineWeight().setValue(0.01388); | |
// add shape | |
long connecter1Id = diagram.addShape(shape, "Dynamic connector", page.getID()); | |
// connect sub-shapes | |
page.connectShapesViaConnector(shapeFromId, ConnectionPointPlace.RIGHT, shapeToId, ConnectionPointPlace.LEFT, connecter1Id); | |
// save Visio drawing | |
diagram.save(dataDir + "ConnectVisioSubShapes_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CopyShape.class); | |
// load a source Visio | |
Diagram srcVisio = new Diagram(dataDir + "Drawing1.vsdx"); | |
// initialize a new Visio | |
Diagram newDiagram = new Diagram(); | |
// add all masters from the source Visio diagram | |
MasterCollection originalMasters = srcVisio.getMasters(); | |
for (Master master : (Iterable<Master>) originalMasters) | |
newDiagram.addMaster(srcVisio, master.getName()); | |
// get the page object from the original diagram | |
Page SrcPage = srcVisio.getPages().getPage("Page-1"); | |
// copy themes from the source diagram | |
newDiagram.copyTheme(srcVisio); | |
// copy pagesheet of the source Visio page | |
newDiagram.getPages().get(0).getPageSheet().copy(SrcPage.getPageSheet()); | |
// copy shapes from the source Visio page | |
for (Shape shape :(Iterable<Shape>) SrcPage.getShapes()) | |
{ | |
newDiagram.getPages().get(0).getShapes().add(shape); | |
} | |
// save the new Visio | |
newDiagram.save(dataDir + "CopyShapes_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetAllConnectedShapes.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get shape by id | |
Shape shape = diagram.getPages().getPage("Page-3").getShapes().getShape(16); | |
// get connected shapes | |
long[] connectedShapeIds = shape.connectedShapes(ConnectedShapesFlags.CONNECTED_SHAPES_ALL_NODES, null); | |
for (long id : connectedShapeIds) | |
{ | |
shape = diagram.getPages().getPage("Page-3").getShapes().getShape(id); | |
System.out.println("ID: " + shape.getID() + "\t\t Name: " + shape.getName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetGluedConnectors.class); | |
// call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "RetrieveShapeInfo.vsd"); | |
// get shape by an ID | |
Shape shape = diagram.getPages().get(0).getShapes().getShape(90); | |
// get all glued 1D shapes | |
long[] gluedShapeIds = shape.gluedShapes(GluedShapesFlags.GLUED_SHAPES_ALL_1_D, null, null); | |
// display shape ID and name | |
for (long id : gluedShapeIds) | |
{ | |
shape = diagram.getPages().get(0).getShapes().getShape(id); | |
System.out.println("ID: " + shape.getID() + "\t\t Name: " + shape.getName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GlueContainerShape.class); | |
// Load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Get a particular page | |
Page page = diagram.getPages().getPage("Page-1"); | |
// The ID of shape which is glue from Aspose.Diagram.Shape. | |
long shapeFromId = 779; | |
// The location on the first connection index where to glue | |
int shapeToBeginConnectionIndex = 72; | |
// The location on the end connection index where to glue | |
int shapeToEndConnectionIndex = 73; | |
// The ID of shape where to glue to Aspose.Diagram.Shape. | |
long shapeToId = 743; | |
// Glue shapes in container | |
page.glueShapesInContainer(shapeFromId, shapeToBeginConnectionIndex, shapeToEndConnectionIndex, shapeToId); | |
// Glue shapes in container using connection name | |
// page.GlueShapesInContainer(fasId, "U05L", "U05R", cabinetId1); | |
// Save diagram | |
diagram.save(dataDir + "GlueContainerShape_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GlueVisioShapes.class); | |
// Load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Get a particular page | |
Page page = diagram.getPages().getPage("Page-1"); | |
// set shape id | |
long shape1_ID = 7; | |
long shape2_ID = 494; | |
// Glue shapes | |
page.glueShapes(shape1_ID, ConnectionPointPlace.CENTER, shape2_ID); | |
// Save diagram | |
diagram.save(dataDir + "GlueVisioShapes_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GroupShapes.class); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
// Initialize an array of shapes | |
Shape[] ss = new Shape[3]; | |
// extract and assign shapes to the array | |
ss[0] = page.getShapes().getShape(15); | |
ss[1] = page.getShapes().getShape(16); | |
ss[2] = page.getShapes().getShape(17); | |
// mark array shapes as group | |
page.getShapes().group(ss); | |
// save visio diagram | |
diagram.save(dataDir + "GroupShapes_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExtractAllImagesFromPage.class); | |
// call a Diagram class constructor to load a VSD diagram | |
Diagram diagram = new Diagram(dataDir + "ExtractAllImagesFromPage.vsd"); | |
// Enter page index i.e. 0 for first one | |
for (Shape shape : (Iterable<Shape>) diagram.getPages().getPage(0).getShapes()) | |
{ | |
// Filter shapes by type Foreign | |
if (shape.getType() == TypeValue.FOREIGN) | |
{ | |
FileOutputStream fos = new FileOutputStream(dataDir+ "ExtractAllImages" + shape.getID() + "_Out.bmp"); | |
fos.write(shape.getForeignData().getValue()); | |
fos.close(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetShapeIcon.class); | |
// Load stencil file to a diagram object | |
Diagram stencil = new Diagram(dataDir + "Timeline.vss"); | |
// get master | |
Master master = stencil.getMasters().getMasterByName("Triangle"); | |
// get byte array | |
byte[] bytes = master.getIcon(); | |
// create an image file | |
FileOutputStream fos = new FileOutputStream(dataDir + "MasterIcon_Out.png"); | |
// write byte array of the image | |
fos.write(bytes); | |
// close array | |
fos.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReplaceShapePicture.class); | |
// call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "ExtractAllImagesFromPage.vsd"); | |
// convert image into bytes array | |
File fi = new File(dataDir + "Picture.png"); | |
byte[] fileContent = Files.readAllBytes(fi.toPath()); | |
// Enter page index i.e. 0 for first one | |
for (Shape shape : (Iterable<Shape>) diagram.getPages().getPage(0).getShapes()) | |
{ | |
// Filter shapes by type Foreign | |
if (shape.getType() == TypeValue.FOREIGN) | |
{ | |
//replace picture shape | |
shape.getForeignData().setValue(fileContent); | |
} | |
} | |
// save diagram | |
diagram.save(dataDir + "ReplaceShapePicture_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(MoveVisioShape.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
// get shape by id | |
Shape shape = page.getShapes().getShape(16); | |
// move shape from its position, it adds values in coordinates | |
shape.move(1, 1); | |
// save diagram | |
diagram.save(dataDir + "MoveVisioShape_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadAllShapeProps.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
for (Shape shape :(Iterable<Shape>) page.getShapes()) | |
{ | |
if (shape.getName() == "Process1") | |
{ | |
for (Prop property :(Iterable<Prop>) shape.getProps()) | |
{ | |
System.out.println(property.getLabel().getValue() + ": " + property.getValue().getVal()); | |
} | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadShapePropByName.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
for (Shape shape :(Iterable<Shape>) page.getShapes()) | |
{ | |
if (shape.getName() == "Process1") | |
{ | |
Prop property = shape.getProps().getProp("Name1"); | |
System.out.println(property.getLabel().getValue() + ": " + property.getValue().getVal()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RerouteConnectors.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
// get a particular connector shape | |
Shape shape = page.getShapes().getShape(18); | |
// set reroute option | |
shape.getLayout().getConFixedCode().setValue(ConFixedCodeValue.NEVER_REROUTE); | |
// save Visio diagram | |
diagram.save(dataDir + "RerouteConnectors_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(RetrieveInheritedFillData.class) + "Shapes/"; | |
// Call the diagram constructor to load a VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Get page by ID | |
Page page = diagram.getPages().getPage("Page-1"); | |
// Get shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// Get the fill formatting values | |
System.out.println(shape.getInheritFill().getFillBkgnd().getValue()); | |
System.out.println(shape.getInheritFill().getFillForegnd().getValue()); | |
System.out.println(shape.getInheritFill().getFillPattern().getValue()); | |
System.out.println(shape.getInheritFill().getShapeShdwObliqueAngle().getValue()); | |
System.out.println(shape.getInheritFill().getShapeShdwOffsetX().getValue()); | |
System.out.println(shape.getInheritFill().getShapeShdwOffsetY().getValue()); | |
System.out.println(shape.getInheritFill().getShapeShdwScaleFactor().getValue()); | |
System.out.println(shape.getInheritFill().getShapeShdwType().getValue()); | |
System.out.println(shape.getInheritFill().getShdwBkgnd().getValue()); | |
System.out.println(shape.getInheritFill().getShdwBkgndTrans().getValue()); | |
System.out.println(shape.getInheritFill().getShdwForegnd().getValue()); | |
System.out.println(shape.getInheritFill().getShdwForegndTrans().getValue()); | |
System.out.println(shape.getInheritFill().getShdwPattern().getValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveShapeInfo.class); | |
//Load diagram | |
Diagram diagram = new Diagram(dataDir+ "RetrieveShapeInfo.vsd"); | |
for (com.aspose.diagram.Shape shape : (Iterable<Shape>) diagram.getPages().getPage(0).getShapes()) | |
{ | |
//Display information about the shapes | |
System.out.println("\nShape ID : " + shape.getID()); | |
System.out.println("Name : " + shape.getName()); | |
System.out.println("Master Shape : " + shape.getMaster().getName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(RetrieveTheParentShape.class) + "Shapes\\"; | |
// Call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get a sub-shape by page name, group shape ID, and then sub-shape ID | |
Shape shape = diagram.getPages().getPage("Page-3").getShapes().getShape(13).getShapes().getShape(2); | |
Shape parentShape = shape.getParentShape(); | |
System.out.println("Parent Shape's Properties:"); | |
System.out.println("Shape ID: " + parentShape.getID()); | |
System.out.println("Shape Name: " + parentShape.getName()); | |
System.out.println("Shape Type: " + parentShape.getType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RotateVisioShape.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
// get shape by id | |
Shape shape = page.getShapes().getShape(16); | |
// Add a shape and set the angle | |
shape.setAngle(190); | |
// Save diagram | |
diagram.save(dataDir + "RotateVisioShape_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SaveVisioShapeInOtherFormats.class); | |
double shapeWidth = 0; | |
double shapeHeight = 0; | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram srcVisio = new Diagram(dataDir + "Drawing1.vsdx"); | |
// 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<Shape>)srcPage.getShapes()) | |
// for the normal shape | |
remShapes.put(shape.getID(), shape.getName()); | |
// iterate through the hash table | |
Enumeration<Long> 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(shapeWidth*0.5, shapeHeight*0.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 | |
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(dataDir + "SaveVisioShapeInOtherFormats_Out.pdf", opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetConnectorAppearance.class); | |
// call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//get a particular page | |
Page page = diagram.getPages().getPage("Page-3"); | |
//get a dynamic connector type shape by id | |
Shape shape = page.getShapes().getShape(18); | |
// set dynamic connector appearance | |
shape.setConnectorsType(ConnectorsTypeValue.STRAIGHT_LINES); | |
//saving Visio diagram | |
diagram.save(dataDir + "SetConnectorAppearance_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetFillData.class); | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir+ "Drawing1.vsd"); | |
//Find a particular shape and update its XForm | |
for (com.aspose.diagram.Shape shape : (Iterable<Shape>) diagram.getPages().get(0).getShapes()) | |
{ | |
if (shape.getNameU().toLowerCase() == "rectangle" && shape.getID() == 1) | |
{ | |
shape.getFill().getFillBkgnd().setValue(diagram.getPages().getPage(0).getShapes().getShape(0).getFill().getFillBkgnd().getValue()); | |
shape.getFill().getFillForegnd().setValue("#ebf8df"); | |
} | |
} | |
// save diagram | |
diagram.save(dataDir+ "SetFillData_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetLineData.class); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "SetLineData.vsd"); | |
// get the page by its name | |
Page page1 = diagram.getPages().getPage("Page-1"); | |
// get shape by its ID | |
Shape shape = page1.getShapes().getShape(1); | |
// set line dash type by index | |
shape.getLine().getLinePattern().setValue(4); | |
// set line weight, defualt in PT | |
shape.getLine().getLineWeight().setValue(2); | |
// set color of the shape's line | |
shape.getLine().getLineColor().getUfe().setF("RGB(95,108,53)"); | |
// set line rounding, default in inch | |
shape.getLine().getRounding().setValue(0.3125); | |
// set line caps | |
shape.getLine().getLineCap().setValue(BOOL.TRUE); | |
// set line color transparency in percent | |
shape.getLine().getLineColorTrans().setValue(50); | |
/* add arrows to the connector or curve shapes */ | |
// select arrow type by index | |
shape.getLine().getBeginArrow().setValue(4); | |
shape.getLine().getEndArrow().setValue(4); | |
// set arrow size | |
shape.getLine().getBeginArrowSize().setValue(ArrowSizeValue.LARGE); | |
shape.getLine().getBeginArrowSize().setValue(ArrowSizeValue.LARGE); | |
// save the Visio | |
diagram.save(dataDir + "SetLineData_Out.vsdx", SaveFileFormat.VSDX); | |
// save diagram | |
diagram.save(dataDir+ "output.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetXFormdata.class); | |
// call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "SetXFormdata.vsd"); | |
//Find a particular shape and update its XForm | |
for(Shape shape :(Iterable<Shape>) diagram.getPages().get(0).getShapes()) | |
{ | |
if (shape.getNameU().toLowerCase() == "process" && shape.getID() == 1) | |
{ | |
shape.getXForm().getPinX().setValue(5); | |
shape.getXForm().getPinY().setValue(5); | |
} | |
} | |
// save diagram | |
diagram.save(dataDir + "SetXFormdata_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ConfigureTimeLine.class); | |
// Load diagram | |
Diagram diagram = new Diagram(dataDir + "DrawingTimeLine.vsdx"); | |
int shapeid = 1; | |
// Get timeline shape | |
Shape timeline = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// Initialize TimeLineHlper object | |
TimeLineHelper timelineHelper = new TimeLineHelper(timeline); | |
// Set start time | |
timelineHelper.setTimePeriodStart(new DateTime(2014, 12, 21)); | |
// Set end time | |
timelineHelper.setTimePeriodFinish(new DateTime(2015, 2, 19)); | |
// Set date format | |
//timelineHelper.setDateFormatForBE(21); | |
// Set date format for intm of timeline shape | |
//timelineHelper.setDateFormatForIntm(21); | |
// Or | |
// Set date format string for start and finish of timeline shape | |
timelineHelper.setDateFormatStringForBE("yyyy-MM-dd"); | |
// Set date format string for intm of timeline shape | |
timelineHelper.setDateFormatStringForIntm("yyyy-MM-dd"); | |
// Save to VDX format | |
diagram.save(dataDir + "ConfigureTimeLine_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RefreshMilestoneWithMilestoneHelper.class); | |
String pageName = "Page-1"; | |
////////////// Modify time line /////////// | |
DateTime startDate = new DateTime(2015, 8, 1); | |
DateTime endDate = new DateTime(2016, 6, 1); | |
DateTime fisYear = startDate; | |
//Load a diagram | |
Diagram diagram = new Diagram(dataDir + "DrawingTimeLine.vsdx"); | |
//Get page | |
Page page = diagram.getPages().getPage(pageName); | |
long timelineId = 1; | |
Shape timeline = diagram.getPages().getPage(pageName).getShapes().getShape(timelineId); | |
double xpos = timeline.getXForm().getPinX().getValue(); | |
double ypos = timeline.getXForm().getPinY().getValue(); | |
// Add milestone | |
String milestoneMasterName = "2 triangle milestone"; | |
//Add Master | |
diagram.addMaster(dataDir + "Timeline.vss", milestoneMasterName); | |
//Add Shape in Visio diagram using AddShape method | |
long milestoneShapeId = diagram.addShape(xpos, ypos, milestoneMasterName, 0); | |
//Get the shape based on ID | |
Shape milestone = page.getShapes().getShape(milestoneShapeId); | |
//Instantiate MilestoneHelper object | |
MilestoneHelper milestoneHelper = new MilestoneHelper(milestone); | |
//Set Milestone Date | |
milestoneHelper.setMilestoneDate(new DateTime(2015, 8, 1)); | |
//Set IsAutoUpdate to true | |
milestoneHelper.setAutoUpdate(true); | |
//RefreshMilesone of timeline shape | |
milestoneHelper.refreshMilestone(timeline); | |
//Save Visio file | |
diagram.save(dataDir + "RefreshMilestone_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RefreshTimeLine.class); | |
// Load diagram | |
Diagram diagram = new Diagram(dataDir + "DrawingTimeLine.vsdx"); | |
int shapeid = 1; | |
// Get timeline shape | |
Shape timeline = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// Initialize TimeLineHlper object | |
TimeLineHelper timelineHelper = new TimeLineHelper(timeline); | |
// Set start time | |
timelineHelper.setTimePeriodStart(new DateTime(2014, 12, 21)); | |
// Set end time | |
timelineHelper.setTimePeriodFinish(new DateTime(2015, 2, 19)); | |
// Set date format | |
timelineHelper.setDateFormatForBE(21); | |
//revive milestones on the timeline | |
timelineHelper.refreshTimeLine(); | |
// Save to VDX format | |
diagram.save(dataDir + "RefreshTimeLine_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetMilestoneProps.class); | |
// Load diagram | |
Diagram diagram = new Diagram(dataDir + "DrawingTimeLine.vsdx"); | |
int shapeid = 22; | |
// Get timeline shape | |
Shape milestone = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// Initialize MilestoneHelper object | |
MilestoneHelper milestoneHelper = new MilestoneHelper(milestone); | |
// Set milestone date | |
milestoneHelper.setMilestoneDate(new DateTime(2014, 10, 21)); | |
// Set date format | |
milestoneHelper.setDateFormat(21); | |
// Set auto update flag | |
milestoneHelper.setAutoUpdate(true); | |
// Set milestone type | |
milestoneHelper.setType(6); | |
// Save to VDX format | |
diagram.save(dataDir + "SetMilestoneProps_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(VerifyConnectedOrGluedShapes.class); | |
// call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// set two shape ids | |
long ShapeIdOne = 15; | |
long ShapeIdTwo = 16; | |
// get Visio page by name | |
Page page = diagram.getPages().getPage("Page-3"); | |
// get Visio shapes by ids | |
Shape ShapedOne = page.getShapes().getShape(ShapeIdOne); | |
Shape ShapedTwo = page.getShapes().getShape(ShapeIdTwo); | |
// determine whether shapes are connected | |
boolean connected = ShapedOne.isConnected(ShapedTwo); | |
System.out.println("Shapes are connected: " + connected); | |
// determine whether shapes are glued | |
boolean glued = ShapedOne.isGlued(ShapedTwo); | |
System.out.println("Shapes are Glued: " + glued); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(RetrieveTheParentShape.class) + "Shapes\\"; | |
// Call a Diagram class constructor to load the VSD diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get a sub-shape by page name, group shape ID, and then sub-shape ID | |
Shape shape = diagram.getPages().getPage("Page-3").getShapes().getShape(13).getShapes().getShape(2); | |
System.out.println("Is it in a Group: " + shape.isInGroup()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddSolutionXMLElement.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// initialize SolutionXML object | |
SolutionXML solXML = new SolutionXML(); | |
// set name | |
solXML.setName("Solution XML"); | |
// set xml value | |
solXML.setXmlValue("XML Value"); | |
// add SolutionXML element | |
diagram.getSolutionXMLs().add(solXML); | |
// save Visio diagram | |
diagram.save(dataDir + "AddSolutionXMLElement_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadSolutionXMLElement.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// iterate through SolutionXML elements | |
for (SolutionXML solutionXML :(Iterable<SolutionXML>) diagram.getSolutionXMLs()) | |
{ | |
// get name property | |
System.out.println(solutionXML.getName()); | |
// get xml value | |
System.out.println(solutionXML.getXmlValue()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddConnectShapes.class); | |
// Load masters from any existing diagram, stencil or template | |
// and add in the new diagram | |
String visioStencil = dataDir + "AddConnectShapes.vss"; | |
// Names of the masters present in the stencil | |
String rectangleMaster = "Rectangle", starMaster = "Star 7", | |
hexagonMaster = "Hexagon", connectorMaster = "Dynamic connector"; | |
int pageNumber = 0; | |
double width = 2, height = 2, pinX = 4.25, pinY = 9.5; | |
// Create a new diagram | |
Diagram diagram = new Diagram(visioStencil); | |
// Add a new rectangle shape | |
long rectangleId = diagram.addShape( | |
pinX, pinY, width, height, rectangleMaster, pageNumber); | |
// Set the new shape's properties | |
Shape shape = diagram.getPages().getPage(pageNumber).getShapes().getShape(rectangleId); | |
shape.getText().getValue().add(new Txt("Rectangle text.")); | |
shape.setName("Rectangle1"); | |
shape.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
shape.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
shape.getLine().getLineColor().setValue("7"); | |
shape.getLine().getLineWeight().setValue(0.03); | |
shape.getFill().getFillBkgnd().setValue("1"); | |
shape.getFill().getFillForegnd().setValue("3"); | |
shape.getFill().getFillPattern().setValue(31); | |
// Add a new star shape | |
pinX = 2.0; | |
pinY = 4.5; | |
long starId = diagram.addShape( | |
pinX, pinY, width, height, starMaster, pageNumber); | |
// Set the star shape's properties | |
shape = diagram.getPages().getPage(pageNumber).getShapes().getShape(starId); | |
shape.getText().getValue().add(new Txt("Star text.")); | |
shape.setName("Star1"); | |
shape.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
shape.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
shape.getLine().getLineColor().setValue("#ff0000"); | |
shape.getLine().getLineWeight().setValue(0.03); | |
shape.getFill().getFillBkgnd().setValue("#ff00ff"); | |
shape.getFill().getFillForegnd().setValue("#0000ff"); | |
shape.getFill().getFillPattern().setValue(31); | |
// Add a new hexagon shape | |
pinX = 7.0; | |
long hexagonId = diagram.addShape( | |
pinX, pinY, width, height, hexagonMaster, pageNumber); | |
// Set the hexagon shape's properties | |
shape = diagram.getPages().getPage(pageNumber).getShapes().getShape(hexagonId); | |
shape.getText().getValue().add(new Txt("Hexagon text.")); | |
shape.setName("Hexagon1"); | |
shape.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
shape.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
shape.getLine().getLineWeight().setValue(0.03); | |
shape.getFill().getFillPattern().setValue(31); | |
// Add master to dynamic connector from the stencil | |
diagram.addMaster(visioStencil, connectorMaster); | |
// Connect rectangle and star shapes | |
Shape connector1 = new Shape(); | |
long connecter1Id = diagram.addShape(connector1, connectorMaster, 0); | |
diagram.getPages().getPage(0).connectShapesViaConnector(rectangleId, ConnectionPointPlace.BOTTOM, | |
starId, ConnectionPointPlace.TOP, connecter1Id); | |
// Connect rectangle and hexagon shapes | |
Shape connector2 = new Shape(); | |
long connecter2Id = diagram.addShape(connector2, connectorMaster, 0); | |
diagram.getPages().getPage(0).connectShapesViaConnector(rectangleId, ConnectionPointPlace.BOTTOM, | |
hexagonId, ConnectionPointPlace.LEFT, connecter2Id); | |
// Save the diagram | |
diagram.save(dataDir + "AddConnectShapes_Out.vsdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ApplyCustomStyleSheets.class); | |
//Load diagram | |
Diagram diagram = new Diagram(dataDir + "ApplyCustomStyleSheets.vsd"); | |
Shape sourceShape = null; | |
// get page by name | |
Page page = diagram.getPages().getPage("Flow 1"); | |
//Find the shape that you want to apply style to | |
for (com.aspose.diagram.Shape shape : (Iterable<Shape>) page.getShapes()) | |
{ | |
if (shape.getName() == "Process") { | |
sourceShape = shape; | |
break; | |
} | |
} | |
StyleSheet customStyleSheet = null; | |
//Find the required style sheet | |
for (StyleSheet styleSheet : (Iterable<StyleSheet>) diagram.getStyleSheets()) | |
{ | |
if (styleSheet.getName() == "CustomStyle1") | |
{ | |
customStyleSheet = styleSheet; | |
break; | |
} | |
} | |
if (sourceShape != null && customStyleSheet != null) | |
{ | |
//Apply text style | |
sourceShape.setTextStyle(customStyleSheet); | |
//Apply fill style | |
sourceShape.setFillStyle(customStyleSheet); | |
//Apply line style | |
sourceShape.setLineStyle(customStyleSheet); | |
} | |
//Save the changed diagram as VDX | |
diagram.save(dataDir + "ApplyCustomStyleSheets_Out.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ApplyFontOnText.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// clear shape text values and chars | |
shape.getText().getValue().clear(); | |
shape.getChars().clear(); | |
// mark character run and add text | |
shape.getText().getValue().add(new Cp(0)); | |
shape.getText().getValue().add(new Txt("TextStyle_Regular\n")); | |
shape.getText().getValue().add(new Cp(1)); | |
shape.getText().getValue().add(new Txt("TextStyle_Bold_Italic\n")); | |
shape.getText().getValue().add(new Cp(2)); | |
shape.getText().getValue().add(new Txt("TextStyle_Underline_Italic\n")); | |
shape.getText().getValue().add(new Cp(3)); | |
shape.getText().getValue().add(new Txt("TextStyle_Bold_Italic_Underline")); | |
// add formatting characters | |
shape.getChars().add(new Char()); | |
shape.getChars().add(new Char()); | |
shape.getChars().add(new Char()); | |
shape.getChars().add(new Char()); | |
//set properties e.g. color, font, size and style etc. | |
shape.getChars().get(0).setIX(0); | |
shape.getChars().get(0).getColor().setValue("#FF0000"); | |
shape.getChars().get(0).getFont().setValue(4); | |
shape.getChars().get(0).getSize().setValue(0.22); | |
shape.getChars().get(0).getStyle().setValue(StyleValue.UNDEFINED); | |
//set properties e.g. color, font, size and style etc. | |
shape.getChars().get(1).setIX(1); | |
shape.getChars().get(1).getColor().setValue("#FF00FF"); | |
shape.getChars().get(1).getFont().setValue(4); | |
shape.getChars().get(1).getSize().setValue(0.22); | |
shape.getChars().get(1).getStyle().setValue(StyleValue.BOLD | StyleValue.ITALIC); | |
//set properties e.g. color, font, size and style etc. | |
shape.getChars().get(2).setIX(2); | |
shape.getChars().get(2).getColor().setValue("#00FF00"); | |
shape.getChars().get(2).getFont().setValue(4); | |
shape.getChars().get(2).getSize().setValue(0.22); | |
shape.getChars().get(2).getStyle().setValue(StyleValue.UNDERLINE | StyleValue.ITALIC); | |
//set properties e.g. color, font, size and style etc. | |
shape.getChars().get(3).setIX(3); | |
shape.getChars().get(3).getColor().setValue("#3333FF"); | |
shape.getChars().get(3).getFont().setValue(4); | |
shape.getChars().get(3).getSize().setValue(0.22); | |
shape.getChars().get(3).getStyle().setValue(StyleValue.BOLD | StyleValue.ITALIC | StyleValue.UNDERLINE); | |
// save diagram | |
diagram.save(dataDir + "ApplyFontOnText_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(FindAndReplaceShapeText.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "FindReplaceText.vsdx"); | |
DateFormat dateFormat = new SimpleDateFormat("dd/MMMM/yyyy"); | |
Date myDate = new Date(System.currentTimeMillis()); | |
Calendar cal = Calendar.getInstance(); | |
// Prepare a collection old and new text | |
Hashtable<String, String> replacements = new Hashtable<String, String>(); | |
replacements.put("[[CompanyName]]", "Research Society of XYZ"); | |
replacements.put("[[CompanyName]]", "Research Society of XYZ"); | |
replacements.put("[[EmplyeeName]]", "James Bond"); | |
replacements.put("[[SubjectTitle]]", "The affect of the internet on social behavior in the industrialize world"); | |
cal.setTime(myDate); | |
cal.add(Calendar.YEAR, -1); | |
System.out.println(dateFormat.format(cal.getTime())); | |
replacements.put("[[TimePeriod]]", dateFormat.format(cal.getTime()) + " -- " + dateFormat.format(myDate)); | |
cal.setTime(myDate); | |
cal.add(Calendar.DAY_OF_MONTH, -7); | |
System.out.println(dateFormat.format(cal.getTime())); | |
replacements.put("[[SubmissionDate]]", dateFormat.format(cal.getTime())); | |
replacements.put("[[AmountReq]]", "$100,000"); | |
cal.setTime(myDate); | |
cal.add(Calendar.DAY_OF_MONTH, 1); | |
System.out.println(dateFormat.format(cal.getTime())); | |
replacements.put("[[DateApproved]]", dateFormat.format(cal.getTime())); | |
// Iterate through the shapes of a page | |
for (Shape shape : (Iterable<Shape>) diagram.getPages().getPage("Page-1").getShapes()) | |
{ | |
Set<String> keys = replacements.keySet(); | |
for(String key: keys) | |
{ | |
for (FormatTxt txt : (Iterable<FormatTxt>) shape.getText().getValue()) | |
{ | |
Txt tx = (Txt)((txt instanceof Txt) ? txt : null); | |
if (tx != null && tx.getText().contains(key)) | |
{ | |
//find and replace text of a shape | |
tx.setText(tx.getText().replace(key, replacements.get(key))); | |
} | |
} | |
} | |
} | |
// Save the diagram | |
diagram.save(dataDir + "FindAndReplaceShapeText_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
static String text = ""; | |
public static void main(String[] args) throws Exception | |
{ | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(GetPlainTextOfVisio.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get Visio diagram page | |
Page page = diagram.getPages().getPage("Page-1"); | |
// iterate through the shapes | |
for (Shape shape :(Iterable<Shape>) page.getShapes()) | |
{ | |
// extract plain text from the shape | |
GetShapeText(shape); | |
} | |
// display extracted text | |
System.out.println(text); | |
} | |
private static void GetShapeText(Shape shape) | |
{ | |
// filter shape text | |
if (shape.getText().getValue().getText() != "") | |
text += (shape.getText().getValue().getText().replaceAll("\\<.*?>","")); | |
// for image shapes | |
if (shape.getType() == TypeValue.FOREIGN) | |
text += (shape.getName()); | |
// for group shapes | |
if (shape.getType() == TypeValue.GROUP) | |
for(Shape subshape : (Iterable<Shape>) shape.getShapes()) | |
{ | |
GetShapeText(subshape); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(InsertTextShape.class) + "Text/"; | |
// create a new diagram | |
Diagram diagram = new Diagram(); | |
// set parameters | |
double PinX = 1, PinY = 1, Width = 1, Height = 1; | |
String text = "Test text"; | |
// add text to a Visio page | |
diagram.getPages().getPage(0).addText(PinX, PinY, Width, Height, text); | |
// save diagram | |
diagram.save(dataDir + "InsertTextShape_out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UpdateShapeText.class); | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram diagram = new Diagram(dataDir + "UpdateShapeText.vsd"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Flow 1"); | |
//Find a particular shape and update its text | |
for (Shape shape :(Iterable<Shape>) page.getShapes()) | |
{ | |
if (shape.getNameU().toLowerCase() == "process" && shape.getID() == 1) | |
{ | |
shape.getText().getValue().clear(); | |
shape.getText().getValue().add(new Txt("New Text")); | |
} | |
} | |
// save diagram | |
diagram.save(dataDir + "UpdateShapeText_Out.vdx", SaveFileFormat.VDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(FormatShapeTextBlockSection.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get the page by its name | |
Page page1 = diagram.getPages().getPage("Page-1"); | |
// get shape by its ID | |
Shape shape = page1.getShapes().getShape(1); | |
// set orientation angle | |
DoubleValue margin = new DoubleValue(4, MeasureConst.PT); | |
// set left, right, top and bottom margins of the shape's text block | |
shape.getTextBlock().setLeftMargin(margin); | |
shape.getTextBlock().setRightMargin(margin); | |
shape.getTextBlock().setTopMargin(margin); | |
shape.getTextBlock().setBottomMargin(margin); | |
// set the text direction | |
shape.getTextBlock().getTextDirection().setValue(TextDirectionValue.VERTICAL); | |
// set the text alignment | |
shape.getTextBlock().getVerticalAlign().setValue(VerticalAlignValue.MIDDLE); | |
// set the text block background color | |
shape.getTextBlock().getTextBkgnd().getUfe().setF("RGB(95,108,53)"); | |
// set the background color transparency in percent | |
shape.getTextBlock().getTextBkgndTrans().setValue(50); | |
// set the distance between default tab stops for the selected shape. | |
shape.getTextBlock().getDefaultTabStop().setValue(2); | |
// save Visio | |
diagram.save(dataDir + "FormatShapeTextBlockSection_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetShapeTextPositionAtBottom.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get shape | |
long shapeid = 1; | |
Shape shape = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// set text position at the bottom, | |
// TxtLocPinY = "TxtHeight*1" and TxtPinY = "Height*0" | |
shape.getTextXForm().getTxtLocPinY().setValue(shape.getTextXForm().getTxtHeight().getValue()); | |
shape.getTextXForm().getTxtPinY().setValue(0); | |
// set orientation angle | |
double angleDeg = 0; | |
double angleRad = (Math.PI / 180) * angleDeg; | |
shape.getTextXForm().getTxtAngle().setValue(angleRad); | |
// save Visio diagram in the local storage | |
diagram.save(dataDir + "SetShapeTextPositionAtBottom_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetShapeTextPositionAtLeft.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get shape | |
long shapeid = 1; | |
Shape shape = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// set text position at the left, | |
// TxtLocPinX = "TxtWidth*1" and TxtPinX = "Width*0" | |
shape.getTextXForm().getTxtLocPinX().setValue(shape.getTextXForm().getTxtWidth().getValue()); | |
shape.getTextXForm().getTxtPinX().setValue(0); | |
// set orientation angle | |
double angleDeg = 0; | |
double angleRad = (Math.PI / 180) * angleDeg; | |
shape.getTextXForm().getTxtAngle().setValue(angleRad); | |
// save Visio diagram in the local storage | |
diagram.save(dataDir + "SetShapeTextPositionAtLeft_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetShapeTextPositionAtRight.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get shape | |
long shapeid = 1; | |
Shape shape = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// set text position at the right, | |
// TxtLocPinX = "TxtWidth*0" and TxtPinX = "Width*1" | |
shape.getTextXForm().getTxtLocPinX().setValue(0); | |
shape.getTextXForm().getTxtPinX().setValue(shape.getXForm().getWidth().getValue()); | |
// set orientation angle | |
double angleDeg = 0; | |
double angleRad = (Math.PI / 180) * angleDeg; | |
shape.getTextXForm().getTxtAngle().setValue(angleRad); | |
// save Visio diagram in the local storage | |
diagram.save(dataDir + "SetShapeTextPositionAtRight_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetShapeTextPositionAtTop.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get shape | |
long shapeid = 1; | |
Shape shape = diagram.getPages().getPage("Page-1").getShapes().getShape(shapeid); | |
// set text position at the top, | |
// TxtLocPinY = "TxtHeight*0" and TxtPinY = "Height*1" | |
shape.getTextXForm().getTxtLocPinY().setValue(0); | |
shape.getTextXForm().getTxtPinY().setValue(shape.getXForm().getHeight().getValue()); | |
// set orientation angle | |
double angleDeg = 0; | |
double angleRad = (Math.PI / 180) * angleDeg; | |
shape.getTextXForm().getTxtAngle().setValue(angleRad); | |
// save Visio diagram in the local storage | |
diagram.save(dataDir + "SetShapeTextPositionAtTop_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateUserDefinedCellInShapeSheet.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by id | |
Shape shape = page.getShapes().getShape(2); | |
// initialize user object | |
User user = new User(); | |
user.setName("UserDefineCell"); | |
user.getValue().setVal("800"); | |
// add user-defined cell | |
shape.getUsers().add(user); | |
// save diagram | |
diagram.save(dataDir + "CreateUserDefinedCellInShapeSheet_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadUserdefinedCellsOfShape.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get shape by id | |
Shape shape = page.getShapes().getShape(1); | |
// extract user defined cells of the shape | |
for (User user :(Iterable<User>) shape.getUsers()) | |
{ | |
System.out.println(user.getName() + ": " + user.getValue().getVal()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(InsertanActiveControl.class) + "VisioActiveXControls/"; | |
// Instantiate Diagram Object | |
Diagram diagram = new Diagram(); | |
// Insert an ActiveX control | |
diagram.getPages().get(0).addActiveXControl(ControlType.IMAGE, 1, 1, 1, 1); | |
// Save diagram | |
diagram.save(dataDir + "InsertActiveXControl_out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(RetrieveActiveXControl.class) + "VisioActiveXControls/"; | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsd"); | |
// get a Visio page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
// get a shape by ID | |
Shape shape = page.getShapes().getShape(1); | |
// get an ActiveX control | |
CommandButtonActiveXControl cbac = (CommandButtonActiveXControl)shape.getActiveXControl(); | |
// set width of the command button control | |
cbac.setWidth(4); | |
// set height of the command button control | |
cbac.setHeight(4); | |
// set caption of the command button control | |
cbac.setCaption("Test Button"); | |
// save diagram | |
diagram.save(dataDir + "RetrieveActiveXControl_out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddSupportOfVisualAids.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get window object by index | |
Window window = diagram.getWindows().get(0); | |
// check dynamic grid option | |
window.setDynamicGridEnabled(BOOL.TRUE); | |
// check connection points option | |
window.setShowConnectionPoints(BOOL.TRUE); | |
// save visio drawing | |
diagram.save(dataDir + "AddSupportOfVisualAids_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddWindowElementInVisio.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// initialize window object | |
Window window = new Window(); | |
// set window state | |
window.setWindowState(WindowStateValue.MAXIMIZED); | |
// set window height | |
window.setWindowHeight(500); | |
// set window width | |
window.setWindowWidth(500); | |
// set window type | |
window.setWindowType(WindowTypeValue.STENCIL); | |
// add window object | |
diagram.getWindows().add(window); | |
// save in any supported format | |
diagram.save(dataDir + "AddWindowElementInVisio_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(DisplayGridsRulersGuidesAndPageBreaks.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get window object by index | |
Window window = diagram.getWindows().get(0); | |
// set visibility of grid | |
window.setShowGrid(BOOL.TRUE); | |
// set visibility of guides | |
window.setShowGuides(BOOL.TRUE); | |
// set visibility of rulers | |
window.setShowRulers(BOOL.TRUE); | |
// set visibility of page breaks | |
window.setShowPageBreaks(BOOL.TRUE); | |
// save diagram | |
diagram.save(dataDir + "DisplayGridsRulersGuidesAndPageBreaks_Out.vsdx", SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RetrieveWindowElementsOfDiagram.class); | |
// load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// iterate through the window elements | |
for (Window window :(Iterable<Window>) diagram.getWindows()) | |
{ | |
System.out.println("ID: " + window.getID()); | |
System.out.println("Type: " + window.getWindowType()); | |
System.out.println("Window height: " + window.getWindowHeight()); | |
System.out.println("Window width: " + window.getWindowWidth()); | |
System.out.println("Window state: " + window.getWindowState()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddingDiagonalWatermark.class); | |
// Load an existing JPG image | |
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dataDir + "aspose-logo.jpg"); | |
// Declare a String object with Watermark Text | |
String theString = "45 Degree Rotated Text"; | |
// Create and initialize an instance of Graphics class | |
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); | |
// Initialize an object of SizeF to store image Size | |
com.aspose.imaging.Size size = graphics.getImage().getSize(); | |
// Creates an instance of Font, initialize it with Font Face & Size | |
com.aspose.imaging.Font font = new com.aspose.imaging.Font("Times New Roman", 20f); | |
// Create an instance of SolidBrush and set its various properties | |
com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); | |
brush.setColor(com.aspose.imaging.Color.getRed()); | |
brush.setOpacity(0); | |
// Initialize an object of StringFormat class and set its various properties | |
com.aspose.imaging.StringFormat format = new com.aspose.imaging.StringFormat(); | |
format.setAlignment(com.aspose.imaging.StringAlignment.Center); | |
format.setFormatFlags(com.aspose.imaging.StringFormatFlags.MeasureTrailingSpaces); | |
// Create an object of Matrix class for transformation | |
com.aspose.imaging.Matrix matrix = new com.aspose.imaging.Matrix(); | |
// First a translation | |
matrix.translate(size.getWidth() / 2, size.getHeight() / 2); | |
// Then a rotation | |
matrix.rotate(-45.0f); | |
// Set the Transformation through Matrix | |
graphics.setTransform(matrix); | |
// Draw the string on Image | |
graphics.drawString(theString, font, brush, 0, 0, format); | |
// Save output to disk | |
image.save(dataDir + "output.jpg"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddingWatermark.class); | |
// Load an existing image in an instance of the Image class | |
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dataDir + "sample.bmp"); | |
// Create and initialize an instance of the Graphics class | |
Graphics graphics = new Graphics(image); | |
// Creates an instance of Font | |
com.aspose.imaging.Font font = new com.aspose.imaging.Font("Times New Roman", 16); | |
// Create an instance of SolidBrush and set its various properties | |
com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); | |
brush.setColor(Color.getBlack()); | |
brush.setOpacity(100); | |
// Draw a String using the SolidBrush object and Font, at specific Point | |
graphics.drawString("Aspose.Imaging for Java", font, brush, | |
new PointF(image.getWidth() / 2, image.getHeight() / 2)); | |
// Export to PNG file format using the default options | |
image.save(dataDir + "output.png", new com.aspose.imaging.imageoptions.PngOptions()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddSignature.class); | |
// Create an instance of Image and load the primary image | |
Image canvas = Image.load(dataDir + "aspose-logo.jpg"); | |
// Create another instance of Image and load the secondary image containing the signature graphics | |
Image signature = Image.load(dataDir + "signature.gif"); | |
// Create an instance of Graphics class and initialize it using the object of the primary image | |
Graphics graphics = new Graphics(canvas); | |
// Call the DrawImage method while passing the instance of secondary image and appropriate location | |
// The following snippet tries to draw the secondary image at the right bottom of the primary image | |
graphics.drawImage(signature, | |
new Point(canvas.getHeight() - signature.getHeight(), canvas.getWidth() - signature.getWidth())); | |
// Save the result in PNG format | |
canvas.save(dataDir + "output.png", new PngOptions()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AvoidPerformanceDegradation.class); | |
// First convert the image to raw PSD format. | |
com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image | |
.load(dataDir + "compressed.psd"); | |
com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions(); | |
saveOptions.setCompressionMethod(CompressionMethod.Raw); | |
psdImage.save(dataDir + "uncompressed.psd", saveOptions); | |
// Now reopen the newly created image. | |
com.aspose.imaging.fileformats.psd.PsdImage uncompressedpsdImage = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image | |
.load(dataDir + "uncompressed.psd"); | |
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(uncompressedpsdImage); | |
// Perform graphics operations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(BufferedImageSimpleConversion.class); | |
Image image = null; | |
// Load an image or create one from the scratch | |
// do processing | |
// Convert to BufferedImage | |
BufferedImage bImage = ImageExtensions.toJava(image); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ColorConversionLoadingImage.class); | |
JpegImage image = (JpegImage) Image.load(dataDir + ""); | |
StreamSource rgbprofile = new StreamSource(new FileInputStream(dataDir + "rgb.icc")); | |
StreamSource cmykprofile = new StreamSource(new FileInputStream(dataDir + "cmyk.icc")); | |
image.setRgbColorProfile(rgbprofile); | |
image.setCmykColorProfile(cmykprofile); | |
Color[] colors = image.loadPixels(new Rectangle(0, 0, image.getWidth(), image.getHeight())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ColorConversionSavingImage.class); | |
JpegImage image = (JpegImage) Image.load(dataDir + ""); | |
StreamSource rgbprofile = new StreamSource(new FileInputStream(dataDir + "rgb.icc")); | |
StreamSource cmykprofile = new StreamSource(new FileInputStream(dataDir + "cmyk.icc")); | |
image.setDestinationRgbColorProfile(rgbprofile); | |
image.setDestinationCmykColorProfile(cmykprofile); | |
image.save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ControllingCacheReallocation.class); | |
// Set the cache type to auto mode | |
// Other supported modes are CacheInMemoryOnly and CacheOnDiskOnly | |
com.aspose.imaging.Cache.setCacheType(CacheType.Auto); | |
// Default value is 0, which means there is no upper limit | |
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte | |
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte | |
// It is not recommended to change the following property as it may greatly affect the performance | |
com.aspose.imaging.Cache.setExactReallocateOnly(false); | |
// No of bytes allocated to disk | |
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount(); | |
// No of bytes allocated to memory | |
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount(); | |
// Create an instance of GifOptions and set its various properties | |
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions(); | |
// Set the color palette for image | |
options.setPalette(new ColorPalette(new Color[]{Color.getRed(), Color.getBlue(), Color.getBlack(), Color.getWhite()})); | |
// Create an instance of stream source and assign it as Source for the instance of GigCreateOptions | |
options.setSource(new StreamSource(new ByteArrayInputStream(new byte[100 * 100 * 4 * 2]), true)); | |
// Create an instance of RasterImage | |
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options,100,100); | |
// Initializes a new instance of the Color struct | |
com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000]; | |
for(int i = 0;i < pixels.length;i++) | |
{ | |
// Set the indexed pixel color to white | |
pixels[i] = Color.getWhite(); | |
} | |
// Save the changed color pixel back to raster image | |
image.savePixels(image.getBounds(), pixels); | |
// No of bytes allocation to disk | |
long diskBytes = Cache.getAllocatedDiskBytesCount(); | |
// No of bytes allocation to memory | |
long memoryBytes = Cache.getAllocatedMemoryBytesCount(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ConvertPartofImagetoBufferedImage.class); | |
Image image = null; | |
// Load an image or create one from the scratch | |
// do processing | |
// Convert part of image to BufferedImage | |
BufferedImage bImage = ImageExtensions.toJava(image, new Rectangle(new Point(0, 0), new Size(100, 100))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AlignHorizontalAndVerticalResolutions.class); | |
TiffImage image = (TiffImage) Image.load(dataDir + "sample.tiff"); | |
// call the align resolution method | |
image.alignResolutions(); | |
// Save the results to output path. | |
image.save(dataDir + "AlignHorizontalAndVeticalResolutionsOfImage_out.tiff"); | |
int framesCount = image.getFrames().length; | |
for (int i = 0; i < framesCount; i++) { | |
TiffFrame frame = image.getFrames()[i]; | |
// All resolutions after aligment must be equal | |
System.out.println("Horizontal and vertical resolutions are equal:" | |
+ ((int) frame.getVerticalResolution() == (int) frame.getHorizontalResolution())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ApplyMedianFilter.class); | |
// Load the noisy image | |
Image image = Image.load(dataDir + "aspose-logo.gif"); | |
// caste the image into RasterImage | |
RasterImage rasterImage = (RasterImage) image; | |
if (rasterImage == null) { | |
return; | |
} | |
// Create an instance of MedianFilterOptions class and set the size. | |
MedianFilterOptions options = new MedianFilterOptions(4); | |
// Apply MedianFilterOptions filter to RasterImage object. | |
rasterImage.filter(image.getBounds(), options); | |
// Save the resultant image | |
image.save(dataDir + "median_test_denoise_out.gif"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment