from net.sourceforge.plantuml import SourceStringReader
from java.io import ByteArrayOutputStream
from net.sourceforge.plantuml import FileFormatOption,FileFormat
from java.lang import String
from java.nio.charset import Charset
source = "@startuml\n scale 600*400\n Bob -> Alice : hello\n @enduml\n";
reader=SourceStringReader(source)
os=ByteArrayOutputStream();
# Write the first image to "os"
desc = reader.generateImage(os, FileFormatOption(FileFormat.SVG));
os.close()
#The XML is stored into svg
svg=String(os.toByteArray(), Charset.forName("UTF-8"))
xf="diagram.svg" # write to file
f=open(xf,"w")
f.write(svg.toString())
f.close()
print "Making:",xf
Ads help maintain this website.