Last active
November 15, 2019 16:23
-
-
Save aspose-com-gists/f188af3c78871e452795ec3489836509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Gist for Aspose.Diagram for Java |
This file contains hidden or 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(RetrieveFontInfo.class) + "Diagrams/"; | |
| // Call the diagram constructor to load diagram | |
| Diagram diagram = new Diagram(dataDir + "RetrieveFontInfo.vsd"); | |
| // Display font default directory | |
| System.out.println(diagram.getDefaultFontDir()); |
This file contains hidden or 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(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 hidden or 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(CreateNewVisio.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportHTMLinStream.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportPageToImage.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToHTML.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToImage.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToPDF.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToSVG.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToSWF.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToXAML.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ExportToXML.class) + "LoadSaveConvert/"; | |
| /* 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 hidden or 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(ExportToXPS.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(ReadVisioDiagram.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(SaveVisioDiagram.class) + "LoadSaveConvert/"; | |
| // 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 hidden or 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(UseDiagramSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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 hidden or 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(UseHTMLSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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"); | |
| // Specify that you want to save tile or not | |
| options.setSaveTitle(true); | |
| // 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 hidden or 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(UseImageSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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 hidden or 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(UsePDFSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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 hidden or 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(UseSVGSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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 hidden or 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(UseSWFSaveOptions.class) + "VisioSaveOptions/"; | |
| // 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 hidden or 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(AddMasterFromStencil.class) + "Masters/"; | |
| // 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 hidden or 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(CheckMasterPresencebyID.class) + "Masters/"; | |
| // 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 hidden or 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(CheckMasterPresencebyName.class) + "Masters/"; | |
| // 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 hidden or 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(GetMasterbyID.class) + "Masters/"; | |
| // 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 hidden or 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(GetMasterbyName.class) + "Masters/"; | |
| // 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 hidden or 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(RetrieveMasterInfo.class) + "Masters/"; | |
| // Call the diagram constructor to load diagram from a VDX file | |
| Diagram diagram = new Diagram(dataDir + "drawing1.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 hidden or 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(ReadDiagramFile.class) + "Diagrams/"; | |
| // Open the stream. Read only access is enough for Aspose.Diagram to | |
| // load a diagram. | |
| InputStream stream = new FileInputStream(dataDir + "ReadDiagramFile.vsd"); | |
| // load diagram | |
| Diagram vsdDiagram = new Diagram(stream); | |
| //Define a new StyleSheet | |
| StyleSheet st = new StyleSheet(); | |
| st.setID(vsdDiagram.getStyleSheets().getCount()+1); | |
| com.aspose.diagram.Char ch = new com.aspose.diagram.Char(); | |
| ch.getColor().setValue("#00ff00"); | |
| ch.setIX(0); | |
| st.getChars().add(ch); | |
| st.getLine().getLineColor().setValue("#ff0000"); | |
| st.getLine().getLinePattern().setValue(1); | |
| st.getLine().getLineWeight().setValue(0.01); | |
| st.getFill().getFillForegnd().setValue("#0000ff"); | |
| st.getFill().getFillPattern().setValue(1); | |
| st.getFill().getShdwPattern().setValue(0); | |
| //Add the stylesheet to Stylesheets collection | |
| vsdDiagram.getStyleSheets().add(st); | |
| for (Shape shape: (Iterable<Shape>)vsdDiagram.getPages().get(0).getShapes()) | |
| { | |
| shape.getLine().getLinePattern().setValue(1); | |
| shape.getFill().getFillPattern().setValue(1); | |
| } | |
| //Apply the stylesheet | |
| vsdDiagram.getPages().get(0).applyStyle(st.getID(), st.getID(), st.getID()); |
This file contains hidden or 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(CopyVisioPage.class) + "Pages/"; | |
| // Call the diagram constructor to load diagram from a VSD file | |
| Diagram originalDiagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
| // 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 hidden or 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(GetVisioPagebyID.class) + "Pages/"; | |
| // 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 hidden or 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(GetVisioPagebyName.class) + "Pages/"; | |
| // 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 hidden or 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(InsertBlankPageInVisio.class) + "Pages/"; | |
| // 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 hidden or 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(RetrievePageInfo.class) + "Pages/"; | |
| // 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 hidden or 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(SetVisioPageOrientation.class) + "Pages/"; | |
| // 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 hidden or 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(BySpecificPrinter.class) + "Print/"; | |
| // 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 hidden or 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(SetPrintJobAndPrinterName.class) + "Print/"; | |
| // 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 hidden or 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(VisioDiagramProtection.class) + "Protection/"; | |
| // 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 hidden or 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(VisioShapeProtection.class) + "Protection/"; | |
| // 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 hidden or 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(AddingNewShape.class) + "Shapes/"; | |
| // 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"); | |
| rectangle.refreshData(); | |
| diagram.save(dataDir + "AddShape_Out.vsdx", SaveFileFormat.VSDX); | |
| System.out.println("Shape has been added."); |
This file contains hidden or 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(CalculateCenterOfSubShapes.class) + "Shapes/"; | |
| // 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 hidden or 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(ChangeShapeSize.class) + "Shapes/"; | |
| // 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 hidden or 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(ConnectVisioSubShapes.class) + "Shapes/"; | |
| // 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 = page.addShape(shape, "Dynamic connector"); | |
| // 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 hidden or 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(CopyShape.class) + "Shapes/"; | |
| // 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 hidden or 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(GetAllConnectedShapes.class) + "Shapes/"; | |
| // 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 hidden or 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(GetGluedConnectors.class) + "Glue/"; | |
| // 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 hidden or 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(GlueContainerShape.class) + "Glue/"; | |
| // 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 hidden or 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(GlueVisioShapes.class) + "Glue/"; | |
| // 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 hidden or 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(GroupShapes.class) + "Shapes/"; | |
| // 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 hidden or 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(ExtractAllImagesFromPage.class) + "Shapes/"; | |
| // 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 hidden or 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(GetShapeIcon.class) + "Shapes/"; | |
| // 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 hidden or 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(ReplaceShapePicture.class) + "Shapes/"; | |
| // 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 hidden or 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(MoveVisioShape.class) + "Shapes/"; | |
| // 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 hidden or 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(ReadAllShapeProps.class) + "Shapes/"; | |
| // 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 hidden or 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(ReadShapePropByName.class) + "Shapes/"; | |
| // 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 hidden or 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(RerouteConnectors.class) + "Shapes/"; | |
| // 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 hidden or 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(RetrieveShapeInfo.class) + "Shapes/"; | |
| // 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 hidden or 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(RotateVisioShape.class) + "Protection/"; | |
| // 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 hidden or 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(SaveVisioShapeInOtherFormats.class) + "Shapes/"; | |
| 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 hidden or 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(SetConnectorAppearance.class) + "Shapes/"; | |
| // 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 hidden or 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(SetFillData.class) + "Shapes/"; | |
| // 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 hidden or 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(SetLineData.class) + "Shapes/"; | |
| // 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 hidden or 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(SetXFormdata.class) + "Shapes/"; | |
| // 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 hidden or 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(ConfigureTimeLine.class) + "Shapes/"; | |
| // 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 hidden or 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(RefreshMilestoneWithMilestoneHelper.class) + "Shapes/"; | |
| 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 hidden or 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(RefreshTimeLine.class) + "Shapes/"; | |
| // 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 hidden or 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(SetMilestoneProps.class) + "Shapes/"; | |
| // 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 hidden or 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(VerifyConnectedOrGluedShapes.class) + "Shapes/"; | |
| // 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 hidden or 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(AddSolutionXMLElement.class) + "SolutionXML/"; | |
| // 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 hidden or 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(ReadSolutionXMLElement.class) + "SolutionXML/"; | |
| // 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 hidden or 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(AddConnectShapes.class) + "TechnicalArticles/"; | |
| // 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.VSDX); |
This file contains hidden or 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(ApplyCustomStyleSheets.class) + "Text/"; | |
| // 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 hidden or 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(ApplyFontOnText.class) + "Text/"; | |
| // 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 hidden or 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(FindAndReplaceShapeText.class) + "Text/"; | |
| // 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 hidden or 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.getSharedDataDir(GetPlainTextOfVisio.class) + "Text/"; | |
| // 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 hidden or 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(UpdateShapeText.class) + "Text/"; | |
| // 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 hidden or 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(FormatShapeTextBlockSection.class) + "TextBoxes/"; | |
| // 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 hidden or 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(SetShapeTextPositionAtBottom.class) + "TextBoxes/"; | |
| // 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 hidden or 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(SetShapeTextPositionAtLeft.class) + "TextBoxes/"; | |
| // 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 hidden or 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(SetShapeTextPositionAtRight.class) + "TextBoxes/"; | |
| // 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 hidden or 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(SetShapeTextPositionAtTop.class) + "TextBoxes/"; | |
| // 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 hidden or 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(CreateUserDefinedCellInShapeSheet.class) + "UserDefinedCells/"; | |
| // 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 hidden or 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(ReadUserdefinedCellsOfShape.class) + "UserDefinedCells/"; | |
| // 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 hidden or 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(AddSupportOfVisualAids.class) + "Window/"; | |
| // 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 hidden or 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(AddWindowElementInVisio.class) + "Window/"; | |
| // 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 hidden or 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(DisplayGridsRulersGuidesAndPageBreaks.class) + "Window/"; | |
| // 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 hidden or 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(RetrieveWindowElementsOfDiagram.class) + "Window/"; | |
| // 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()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment