 |
Creating EPS image from a string using PlantUML and Java API
Source code name: "uml_diagram1_eps.py"
Programming language: Python
Topic: Plots/Diagrams
DMelt Version 2.2. Last modified: 02/13/1972. License: Pro
https://datamelt.org/code/cache/uml_diagram1_eps_1145.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
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\nscale 600*400\n Alex -> Roman : hello\n Tania -> Steve : connect\n @enduml\n";
reader=SourceStringReader(source)
os=ByteArrayOutputStream();
# Write the first image to "os"
desc = reader.generateImage(os, FileFormatOption(FileFormat.EPS));
os.close()
svg=String(os.toByteArray(), Charset.forName("UTF-8"))
xf="diagram.eps" # write to file
f=open(xf,"w")
f.write(svg.toString())
f.close()
print "Making:",xf
You see the box below because you did not login.