Добавить водяной знак в Visio
Contents
[
Hide
]
Создание Diagram
Aspose.Diagram for Java позволяет читать и создавать Microsoft Visio диаграммы из ваших собственных приложений без автоматизации. Первым шагом при создании новых документов является создание diagram. Затемдобавить фигуры и соединителидля создания diagram. Используйте конструктор по умолчаниюDiagram класс для создания нового 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.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); |
Этот пример работает следующим образом:
- Создайте объект класса Diagram.
- Добавить водяной знак на visio на странице
- Вызовите метод Save объекта класса Diagram, а также передайте полный путь к файлу и объект DiagramSaveOptions.
Пример программирования добавления водяного знака
В следующем примере кода показано, как добавить водяной знак в файл Visio 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.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); |