Visio - Perl extension mainpulating XML based Visio files
To create a viso vdx file, create multiple pages, reorient one of the pages:
my $v = new Visio(); $v->set_title('wabla wabla'); $v->set_timeCreated(); $v->set_timeSaved() my $page = $v->addpage(); $page->set_name('my page'); $page->set_heightWidth(8,11); my $page2 = $v->addpage(); $page2->set_name('my page2'); $v->toFile('myvisofile.vdx');
Visio is an alpha stage library to create and manipulate Microsoft Visio drawings.
Visio is an alpha stage library to create and manipulate Microsoft Visio drawings. Currently it can only create drawings from scratch, and can not create a usable object model from a pre-existing file. The Visio module is however able to extract stencils from pre-existing files and insert them into your new drawings. This is helpfull as it is fairly difficult to make a nice drawing on your own via the current Visio perl module API. This is my first public Perl module, and I'm sure there are tons of mistakes. Please feel free to communicate any design flaws or reworking you may feel would make Visio more usable and approachable.
A new Visio document is created using the new method:
my $vDoc = new Visio();
By default the document is completely empty and the document creator is set to 'perl-visio'. This can be overwritten by use of the set_creator method.
Visio document is returned as an XML string.
my $vString = $vDoc->toString;
Visio doc is written out to an XML file.
$vDoc->toFile('myfile.vdx');
libxml2 doc element is returned
$vDoc->toXmlDoc();
Sets Document title
$vDoc->set_title('my title');
Sets Document subject
$vDoc->set_subject('my subject');
Sets Document manager field
$vDoc->set_manager('my manager');
Sets company filed in document.
$vDoc->set_company('my company');
Sets Document description.
$vDoc->set_desc('my really good description');
Sets Document creator field.
$vDoc->set_creator('just me');
Set's document time created information. If time is not passed, the current time (UTC) is set.
$vDoc->set_timeCreated();
Set's document time saved information. If time is not passed, the current time (UTC) is set.
$vDoc->set_timeSaved();
Takes in argument of $time, which is in the format of the perl time() function. Returns a $visioTimeString formatted string.
$vDoc->set_timeCreated(Visio::visio_timeformat(time())); is equivilent to: $vDoc->set_timeCreated();
searches the visio masters (stencils). filters can be specifed:
$vDoc->find_master_dom({name=>'myrectangle'})
returns a libxml nodelist object of all stencils that had name 'myractangle'. Not specifying filters returns all stencils.
filters avaliable:
name
A new Visio page is created in a Visio document.
my $vPage1 = $vDoc->addpage();
Sets the name of the page
$vPage->set_name('mypage');
Sets a page's height and width. In inches by default:
$vPage->setheightWidth(8,11);
creates a pageSheet method if needed under this page
my $pageSheet = $vPage->create_pageSheet();
For the most part one shouldn't need to directly use these methods
new creates (if one does not already exist) a new child PageSheet element node under $parentNode, which is a libxml2 object.
returns the PageSheet libxml2 node
my $pageSheetNode = $pageSheet->getnode();
creates a PageProps object and element under the current PageSheet
new creates (if one does not already exist) a new child PageProps element node under $parentNode, which is a libxml2 object.
returns the PageProps libxml2 node
my $pagePropsNode = $pageProps->getnode();
sets the page width of this PageProps node. Default unit is in inches.
$pageProps->set_PageWidth($width);
sets the page height of this PageProps node. Default unit is in inches.
$pageProps->set_PageHeight($height);
None by default.
If you have a mailing list set up for your module, mention it here.
Aamer Akhter, <aakhter@cisco.com> <aakhter@gmail.com>
Copyright 2005 by Aamer Akhter
This library is free software; you can redistribute it and/or modify it under the same terms as in LICENSE and MSPATENTLICENSE files.
"This product may incorporate intellectual property owned by Microsoft Corporation. The terms and conditions upon which Microsoft is licensing such intellectual property may be found at http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp"
To install Visio, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Visio
CPAN shell
perl -MCPAN -e shell install Visio
For more information on module installation, please visit the detailed CPAN module installation guide.