Add Watermark to Visio
Creating a Diagram
Aspose.Diagram for Java lets you read and create Microsoft Visio diagrams from within your own applications, without Microsoft Office Automation. The first step when creating new documents, is to create a diagram. Then add shapes and connectors to build up the diagram. Use the default constructor of Diagram class to create a new diagram.
Programming Sample
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateDiagram.class); | |
// Create directory if it is not already present. | |
File file = new File(dataDir); | |
if (!file.exists()) | |
file.mkdir(); | |
// initialize a new Diagram | |
Diagram diagram = new Diagram(); | |
// save in the VSDX format | |
diagram.save(dataDir + "CreateDiagram_Out.vsdx", SaveFileFormat.VSDX); |
This example work as follows:
- Create an object of the Diagram class.
- Add watermark to visio in page
- Call Save method of the Diagram class object and also pass complete file path and the DiagramSaveOptions object.
Add watermark Programming Sample
The following example code shows how to add watermark in the Visio diagram.
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AddWatermarkToVisio.class); | |
// load diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// get page by name | |
Page page = diagram.getPages().getPage("Page-1"); | |
double pinx = page.getPageSheet().getPageProps().getPageWidth().getValue() / 2; | |
double piny = page.getPageSheet().getPageProps().getPageHeight().getValue() / 2; | |
double width = page.getPageSheet().getPageProps().getPageWidth().getValue(); | |
double height =page.getPageSheet().getPageProps().getPageHeight().getValue(); | |
//Add watermark | |
Shape shape = page.addText(pinx, piny, width, height, "Test text","Calibri","#a5a5a5",0.25); | |
// save diagram | |
diagram.save(dataDir + "ApplyFontOnText_Out.vsdx", SaveFileFormat.VSDX); |