Library/Utilities to convert Microsoft (MS) Visio Documents and Stencils (VSS and VSD) to SVG.
There are tons of publicly available MS Visio stencils, for example the Cisco ones or the stencils from VisioCafe.
This library and utilities were created to be able to convert these stencils to SVG and reuse them outside of Microsoft Visio, in programs like yEd, Inkscape, Dia, Calligra Flow...
This library is mainly the glue between librevenge/libvisio and libemf2svg.
libemf2svg is another library of mine. It was developed to handle MS EMF (Enhanced Metafile) blobs which constitute most of Visio VSS shapes.
Librevenge/Libvisio would otherwise only dump the EMF blob as base64 in an <image> SVG tag, which most viewer/editor/browser would be unable to display.
Libvisio2svg is licensed under GPLv2.
Commands to build this project:
# CMAKE_INSTALL_PREFIX is optional, default is /usr/local/
$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/
# compilation
$ make
# installation
$ make install
Convert VSS:
# conversion
$ vss2svg-conv -i ./2960CX.vss -o ./out/ -s 4.5
$ ls out/
'Cisco R42610 Front.svg' 'WS-C2960CX-8PC-L Rear.svg' 'WS-C2960CX-8TC-L Rear.svg'
'WS-C2960CX-8PC-L Front.svg' 'WS-C2960CX-8TC-L Front.svg'
# help
$ vss2svg-conv --help
Convert VSD:
# conversion
$ vsd2svg-conv -i ./my.VSD -o ./out/ -s 7
$ ls out/
Page-1.svg Page-2.svg Page-3.svg Page-4.svg
# help
$ vsd2svg-conv --help
Convert Visio Documents:
#include <string>
#include <stdlib.h>
#include <sys/types.h>
#include <visio2svg/Visio2Svg.h>
#include <unordered_map>
// Put visio file in an std::string (not detailed here)
std::string visio_in;
// Initialize converter and output map
visio2svg::Visio2Svg converter;
std::unordered_map<std::string, std::string> out;
// return code
int ret = 0;
// Pick one of the following
// Convert vsd documents
ret = converter.vsd2svg(visio_in, out);
// Convert vss (Stencils) documents
ret = converter.vss2svg(visio_in, out);
// or with rescaling
ret = converter.vsd2svg(visio_in, out, 4.5);
ret = converter.vss2svg(visio_in, out, 4.5);
if ( ret )
cerr << "Conversion errors occured" << "\n";
// Do something with the output
for (const auto &rule_pair : out) {
cout << "Sheet Title: " << rule_pair.first <<std::endl;
cout << rule_pair.second << std::endl;
}
This library also comes with a RVNG generator to recover sheets titles:
#include <librevenge-stream/librevenge-stream.h>
#include <librevenge-generators/librevenge-generators.h>
#include <librevenge/librevenge.h>
#include <libvisio/libvisio.h>
#include <visio2svg/TitleGenerator.h>
// put the Visio document in an RVNGStream (not detailed here)
librevenge::RVNGStringStream input;
/* or from file
librevenge::RVNGFileStream input;
*/
// Recover Titles of each sheets
librevenge::RVNGStringVector output_names;
visio2svg::TitleGenerator generator_names(output_names);
ret = libvisio::VisioDocument::parseStencils(&input, &generator_names);
/* or this for vsd
ret = libvisio::VisioDocument::parse(&input, &generator_names);
*/
if (!ret || output_names.empty()) {
std::cerr << "ERROR: Failed to recover sheets titles failed!"
<< std::endl;
return 1;
}
// do something with the names
for (unsigned k = 0; k < output_names.size(); ++k) {
std::cout << output_names[k].cstr() << std::endl;
}