public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); $pages = $diagram->getPages(); $i = 0; while ($i < (int) (string) $pages->getCount()) { $page = $pages->get($i); $shapes = $page->getShapes(); $j = 0; while ($j < (int) (string) $shapes->getCount()) { $shape = $shapes->get($j); if ($shape->getNameU() == "Process") { # Initialize user object $user = new User(); $user->setName("UserDefineCell"); $user->getValue()->setVal("800"); # Add user-defined cell $shape->getUsers()->add($user); } $j += 1; } $i += 1; } # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "UserDefinedCells.vdx", $saveFileFormat->VDX); print "Created User-defined Cell in the ShapeSheet." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "drawing.vsd"); $page = $diagram->getPages()->getPage("Flow 1"); $shape = $page->getShapes()->getShape(1); $shape->getProtection()->getLockAspect()->setValue(1); $shape->getProtection()->getLockBegin()->setValue(1); $shape->getProtection()->getLockCalcWH()->setValue(1); $shape->getProtection()->getLockCrop()->setValue(1); $shape->getProtection()->getLockCustProp()->setValue(1); $shape->getProtection()->getLockDelete()->setValue(1); $shape->getProtection()->getLockEnd()->setValue(1); $shape->getProtection()->getLockFormat()->setValue(1); $shape->getProtection()->getLockFromGroupFormat()->setValue(1); $shape->getProtection()->getLockGroup()->setValue(1); $shape->getProtection()->getLockHeight()->setValue(1); $shape->getProtection()->getLockMoveX()->setValue(1); $shape->getProtection()->getLockMoveY()->setValue(1); $shape->getProtection()->getLockRotate()->setValue(1); $shape->getProtection()->getLockSelect()->setValue(1); $shape->getProtection()->getLockTextEdit()->setValue(1); $shape->getProtection()->getLockThemeColors()->setValue(1); $shape->getProtection()->getLockThemeEffects()->setValue(1); $shape->getProtection()->getLockVtxEdit()->setValue(1); $shape->getProtection()->getLockWidth()->setValue(1); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "ProtectUnprotectShape.vdx", $saveFileFormat->VDX); print "Applied protection on shape successfully!" . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # convert image into bytes array $fi = new File($dataDir . "star.png"); $files = new Files(); $file_content = $files->readAllBytes($fi->toPath()); $shapes = $diagram->getPages()->getPage("Flow 1")->getShapes(); $i = 0; $typeValue = new TypeValue(); while ($i < (int) (string) $shapes->getCount()) { $shape = $shapes->get($i); # Filter shapes by type Foreign if ($shape->getType() == $typeValue->FOREIGN) { # replace picture shape $shape->getForeignData()->setValue($file_content); } $i += 1; } # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "ReplacePictureShape.vdx", $saveFileFormat->VDX); print "Replaced picture shape successfully!" . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Basic_Shapes.vsd"); # get Visio page $page = $diagram->getPages()->getPage(0); # initialize a new Layer class object $layer = new Layer(); # set Layer name $layer->getName()->setValue("Layer2"); # set Layer Visibility $layer->getVisible()->setValue(2); # add Layer to the particular page sheet $page->getPageSheet()->getLayers()->add($layer); # add a new shape $shape_id = $page->addShape(3.0, 3.0, 0.36, 0.36, "Circle"); # get the Shape object $shape = $page->getShapes()->getShape($shape_id); # assign this new Layer $shape->getLayerMem()->getLayerMember()->setValue((string) $layer->getIX()); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "AddNewLayer.vdx", $saveFileFormat->VDX); print "Added a new Layer in the Visio Diagram." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "drawing.vdx"); $pages = $diagram->getPages(); $count = 0; while ($count < (int) (string) $pages->getCount()) { $page = $pages->get($count); $shapes = $page->getShapes(); $i = 0; while ($i < (int) (string) $shapes->getCount()) { $shape = $shapes->get($i); if ($shape->getNameU() == "Process") { $users = $shape->getUsers(); $j = 0; while ($j < (int) (string) $users->getCount()) { $user = $users->get($j); print "Name: " . $user->getNameU() . " Value: " . $user->getValue()->getVal() . " Prompt: " . $user->getPrompt()->getValue(); $j += 1; } break; } $i += 1; } $count += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); $shapes = $diagram->getPages()->getPage("Flow 1")->getShapes(); $i = 0; while ($i < (int) (string) $shapes->getCount()) { $shape = $shapes->get($i); #puts shape.getName().to_s if ($shape->getName() == "Process") { # Add shape1 in first two layers. Here "0;1" are indexes of the layers $layer = $shape->getLayerMem(); $layer->getLayerMember()->setValue("0;1"); } elseif ($shape->getName() == "Preparation") { # Remove shape2 from all the layers $layer = $shape->getLayerMem(); $layer->getLayerMember()->setValue(""); } $i += 1; } # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "Layers.vdx", $saveFileFormat->VDX); print "Configured Shape Objects with Layers in Visio." . PHP_EOL; }
public static function run($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); #page = diagram.getPages().getPage(page_id) $page = $diagram->getPages()->getPage(0); print "Page ID : " . $page->getName() . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram(); # Save as VDX $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "CreateDiagram.vdx", $saveFileFormat->VDX); print "Created visio diagram successfully!" . PHP_EOL; }
public static function run($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); # Save as Html $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "Diagram.html", $saveFileFormat->HTML); print "Exported visio diagram to HTML." . PHP_EOL; }
public static function export_to_vtx($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); # Save as VTX $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "Diagram.vtx", $saveFileFormat->VTX); print "Exported visio diagram to VTX." . PHP_EOL; }
public static function get_page_object_by_name($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); # Set page name $page_name = "Flow 1"; # Get page object by name $page = $diagram->getPages()->getPage($page_name); print "Page : " . (string) $page . PHP_EOL; }
public static function check_presence_master_by_name($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "Drawing.vsd"); # Set master name $master_name = "Background tranquil .2"; # check master object by name $is_present = $diagram->getMasters()->isExist($master_name); print "Master Presence : " . (string) $is_present . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # Add a shape and set the angle $diagram->getPages()->getPage(0)->getShapes()->getShape(1)->setAngle(190); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "RotateShape.vdx", $saveFileFormat->VDX); print "Rotated shape." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # Add comment $diagram->getPages()->getPage(0)->addComment(7.205905511811023, 3.880708661417323, "test@"); # Save as VDX $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "AddComment.vdx", $saveFileFormat->VDX); print "Added comment successfully!" . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "drawing.vsd"); # remove all macros $diagram->setVbProjectData(null); # Save as VDX $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "RemoveAllMacros.vdx", $saveFileFormat->VDX); print "Removed all macros from diagram successfully!" . PHP_EOL; }
public static function get_master_object_by_name($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); # Set master name $master_name = "Background tranquil .2"; # Get master object by name $master = $diagram->getMasters()->getMasterByName($master_name); print "Master ID : " . (string) $master->getID() . PHP_EOL; print "Master Name : " . (string) $master->getName() . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "drawing.vsd"); $fonts = $diagram->getFonts(); $i = 0; while ($i < sizeof($fonts->getCount())) { $font = $fonts->get($i); # Display information about the fonts print $font->getName(); $i += 1; } }
public static function run($dataDir = null) { # Call the diagram constructor to load diagram from a VSD file $diagram = new Diagram($dataDir . "drawing.vsd"); $masters = $diagram->getMasters(); $i = 0; while ($i < sizeof($masters->getCount())) { $master = $masters->get($i); print "Master ID : " . (string) $master->getID() . PHP_EOL; print "Master Name : " . (string) $master->getName() . PHP_EOL; $i += 1; } }
public static function run($dataDir = null) { # Crezate instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); $connectors = $diagram->getPages()->getPage(0)->getConnects(); $i = 0; while ($i < sizeof($connectors->getCount())) { $connector = $connectors->get($i); # Display information about the Connectors print "From Shape ID : " . (string) $connector->getFromSheet() . PHP_EOL; print "To Shape ID : " . (string) $connector->getToSheet() . PHP_EOL; $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vdx"); $solution_xmls = $diagram->getSolutionXMLs(); $i = 0; while ($i < (int) (string) $solution_xmls->getCount()) { $solution_xml = $solution_xmls->get($i); # get name property print "Name: " . (string) $solution_xml->getName(); # get xml value print "Value:" . (string) $solution_xml->getXmlValue(); $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing1.vsd"); $shapes = $diagram->getPages()->getPage(0)->getShapes(); $i = 0; while ($i < (int) (string) $shapes->getCount()) { $shape = $shapes->get($i); # Display information about the shapes print "Shape ID : " . (string) $shape->getID() . PHP_EOL; print "Name : " . (string) $shape->getName() . PHP_EOL; print "Master Shape : " . (string) $shape->getMaster()->getName() . PHP_EOL; $i += 1; } }
public static function read_shape_property_by_name($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); $shapes = $diagram->getPages()->getPage(0)->getShapes(); $i = 0; while ($i < (int) (string) $shapes->getCount()) { $shape = $shapes->get($i); if ($shape->getName() == "Process") { $property = $shape->getProps()->getProp("Cost"); print $property->getLabel()->getValue() . ": " . $property->getValue()->getVal() . PHP_EOL; } $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # get window object by index $window = $diagram->getWindows()->get(0); # check dynamic grid option $window->setDynamicGridEnabled(1); # check connection points option $window->setShowConnectionPoints(1); # Save as VDX $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "AddDynamicGridsAndConnectionPoints.vsx", $saveFileFormat->VSX); print "Added Support of Dynamic Grids and Connection Points in the Visio Drawings." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # get Visio page $page = $diagram->getPages()->getPage(0); $layers = $page->getPageSheet()->getLayers(); $i = 0; while ($i < $layers->getCount()) { $layer = $layers->get($i); print "Name: " . (string) $layer->getName()->getValue(); print "Visibility: " . (string) $layer->getVisible()->getValue(); print "Status: " . (string) $layer->getStatus()->getValue(); $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing1.vsd"); # get master $master = $diagram->getMasters()->getMasterByName("Circle"); # get byte array $bytes = $master->getIcon(); # create an image file $fos = new FileOutputStream($dataDir . "star.png"); # write byte array of the image $fos->write($bytes); # close array $fos->close(); print "Get shape icon, please check the output file." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "drawing.vdx"); # Get a particular shape $shape = $diagram->getPages()->getPage("Flow 1")->getShapes()->getShape(1); $hyperlinks = $shape->getHyperlinks(); $i = 0; while ($i < (int) (string) $hyperlinks->getCount()) { $hyperlink = $hyperlinks->get($i); print "Address: " . (string) $hyperlink->getAddress()->getValue(); print "Sub Address: " . (string) $hyperlink->getSubAddress()->getValue(); print "Description: " . (string) $hyperlink->getDescription()->getValue(); $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); $windows = $diagram->getWindows(); $i = 0; while ($i < (int) (string) $windows->getCount()) { $window = $windows->get($i); print "ID: " . (string) $window->getID(); print "Type: " . (string) $window->getWindowType(); print "Window height: " . (string) $window->getWindowHeight(); print "Window width: " . (string) $window->getWindowWidth(); print "Window state: " . (string) $window->getWindowState(); $i += 1; } }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # Access a particular page $page = $diagram->getPages()->getPage("Flow 1"); # get a particular connector shape $shape = $page->getShapes()->getShape(1); # set reroute option $conFixedCodeValue = new ConFixedCodeValue(); $shape->getLayout()->getConFixedCode()->setValue($conFixedCodeValue->NEVER_REROUTE); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "SelectRerouteOption.vdx", $saveFileFormat->VDX); print "Seleted reroute option of the connector shape." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # Access a particular page $page = $diagram->getPages()->getPage("Flow 1"); # get a particular connector shape $shape = $page->getShapes()->getShape(1); # set dynamic connector appearance $connectorsTypeValue = new ConnectorsTypeValue(); $shape->setConnectorsType($connectorsTypeValue->STRAIGHT_LINES); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "SetShapeAppearance.vdx", $saveFileFormat->VDX); print "Set appearnce of the connector type shape." . PHP_EOL; }
public static function run($dataDir = null) { # Create instance of Diagram $diagram = new Diagram($dataDir . "Drawing.vsd"); # Get a particular shape $shape = $diagram->getPages()->getPage("Flow 1")->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")); $shape->getText()->getValue()->add(new Cp(1)); $shape->getText()->getValue()->add(new Txt("TextStyle_Bold_Italic")); $shape->getText()->getValue()->add(new Cp(2)); $shape->getText()->getValue()->add(new Txt("TextStyle_Underline_Italic")); $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()); $style_value = new StyleValue(); # Set properties e.g. color, font, size and style etc. $shape->getChars()->getChar(0)->setIX(0); $shape->getChars()->getChar(0)->getColor()->setValue("#FF0000"); $shape->getChars()->getChar(0)->getFont()->setValue(4); $shape->getChars()->getChar(0)->getSize()->setValue(0.22); $shape->getChars()->getChar(0)->getStyle()->setValue($style_value->UNDEFINED); # Set properties e.g. color, font, size and style etc. $shape->getChars()->getChar(1)->setIX(1); $shape->getChars()->getChar(1)->getColor()->setValue("#FF00FF"); $shape->getChars()->getChar(1)->getFont()->setValue(4); $shape->getChars()->getChar(1)->getSize()->setValue(0.22); (int) (string) $shape->getChars()->getChar(1)->getStyle()->setValue((string) $style_value->BOLD | (string) $style_value->ITALIC); # Set properties e.g. color, font, size and style etc. $shape->getChars()->getChar(2)->setIX(2); $shape->getChars()->getChar(2)->getColor()->setValue("#00FF00"); $shape->getChars()->getChar(2)->getFont()->setValue(4); $shape->getChars()->getChar(2)->getSize()->setValue(0.22); (int) (string) $shape->getChars()->getChar(2)->getStyle()->setValue((string) $style_value->UNDERLINE | (string) $style_value->ITALIC); # Save diagram $saveFileFormat = new SaveFileFormat(); $diagram->save($dataDir . "AddShapeTextAndStyles.vdx", $saveFileFormat->VDX); print "Added shape text and styles." . PHP_EOL; }