Windows Metafile WMF/EMF Export is really wanted

+1 vote
asked Jul 24, 2018 in Wanted features by nAlAz117 (240 points)

Hallo,

i wish to revive a situation with WMF/EMF Export from plantuml. It is sufficient Information about WMF facilty in Java domain on internet

http://public.beuth-hochschule.de/~knabe/java/UmlDiagramsInText.shtml
https://stackoverflow.com/questions/38760961/creating-wmf-file-from-java-bufferedimage
http://java.freehep.org/
http://java.freehep.org/vectorgraphics/index.html
https://github.com/ttyangf/svg2emf/find/master
http://jdocs.nomagic.com/185/com/nomagic/magicdraw/export/image/ImageExporter.html

Lot of very popular apps such as MathMagic, MathType, Illustrator, Xara Designer, Corel apps etc. have a metafile feature. The biggest goal of metafile is a scalability! Additionaly it is possible to transfer 2D in 3D (for example Xara 3D Maker). I wrote Metafile handling in C/C++. It was really not so difficult.

Best regards
 

related to an answer for: Export to windows meta file

2 Answers

0 votes
answered Jul 26, 2018 by StefanDensow (280 points)

What about converting SVG to WMF? See: https://stackoverflow.com/questions/31748727/how-to-convert-an-svg-file-to-wmf-format

I suppose you can do that entirely on the command-line, without launching the Inkscape GUI.

commented Jul 26, 2018 by anonymous
It is a bad way. After implementation of hidden I/O pipe over clipboard (Text to BMP) and using of JNI in C++ parent app no more command-line or shellexecute needed! Instead 2 or more seconds for processing of some UML input and rendering inside of plantuml and transfer of image in parent app i have only 0.02 sec for the same!!! But for clear and nice representation of UML output in text processing systems a DPI feature can be used but in final documents it must be scaled to fit in the page width. And scaling of pixels brings always an aliasing problem. This is not necessary for metafiles. And finally not all text processing apps have a SVG facility. Until now the leading companies for Mathematical Formulas prefer to use metafile standard and not SVG!
0 votes
answered Jul 26, 2018 by plantuml (298,440 points)
We really need help here. Generating WMF/EMF files from Java is not that easy.

One issue with FreeHEP is that it's only available under LGPL, and it looks quite old (Last Published: 2013-04-05).

For EPS and SVG we have built our own generators (see https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/eps/EpsGraphics.java or https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/eps/EpsGraphics.java )

Let's start by something very simple : could someone provide us a Java code snipset that draw a simple rectangle and export it to WWF/EMF ?
commented Jul 27, 2018 by nAlAz117 (240 points)
OK! For the start i will provide to you my C/C++ code snipset for metafile handling. First - a creation of metafile in Windows environment is very straightforward. You need only to encapsulate your rendering block by metafile prolog part before and epilog part after. You need to differ export of metafile in a file or in clipboard. For WMF export in a file you must create so called placeable metafile with a special header, for clipboard it is easier. Also on my opinion principally you do not need special Java libraries for metafile support. Everything is here as Windows API that can be called from Java. UML operates with only 2D graphical primitives (lines, fonts, shapes and colors) – exactly what WMF usually contains. Additionally in archive is Test.WMF that contains/shows export from my app.
https://www31.zippyshare.com/v/VyMBxQmY/file.html
I hope that this information can help you to start WMF implementation in plantuml. Anyway I will take a look on internet for similar code snipsets written in Java.
Best regards
commented Jul 27, 2018 by plantuml (298,440 points)
Thanks for your file, it's a good start.

> Also on my opinion principally you do not need special Java libraries for metafile support.
> Everything is here as Windows API that can be called from Java.
>
This is really an issue.
Calling Windows API from Java is not simple.
And PlantUML is written to be fully portable (that is, not only running on Windows).

So we have to find a Java implementation of this Windows API.
commented Jul 27, 2018 by plantuml (298,440 points)
The following one looks interesting :
https://github.com/papnkukn/wmf

It's written in pure .NET, so porting it in pure Java should be possible (although it needs some work!)

The demo contains almost everyting we need:
https://github.com/papnkukn/wmf/blob/master/sample/Program.cs

So if someone takes the time to convert this to pure Java, we will integrate it into PlantUML.
We can offer adding names into the hall of fame :-)
http://www.plantuml.com/plantuml/uml/IomjoSWlAWO0
commented Jul 27, 2018 by nAlAz117 (240 points)
Yes. We have a Progress!
Using this
https://www.tangiblesoftwaresolutions.com/product_details/csharp_to_java_converter_details.html
having this
https://www25.zippyshare.com/v/YfOfTxw3/file.html
pass my nick
Best wishes
PS. It is only converted. I am a NOT Java Guru...
commented Jul 28, 2018 by plantuml (298,440 points)
Indeed, this is a big progress!

The converted Java file don't compile because some part were not translated, but most of the code is nicely translated.

If you're ok with that, we can create a new independant "wmf" project on https://github.com/plantuml/ so that expert that know both Java and .NET may help us.

Does it sound good to you ?
commented Jul 28, 2018 by nAlAz117 (240 points)
Yea! No problem with this. I hope that brings nice results. May be i will take a look on converted java code. Anyway 30 years experience in programming...
commented Jul 28, 2018 by nAlAz117 (240 points)
Additionally i have compiled C# project just for check - is everything here? All is OK!
Take a look and test
https://www31.zippyshare.com/v/PT0kBisK/file.html
pass my nick
commented Jul 30, 2018 by plantuml (298,440 points)
Ok, thanks.
We have imported code here https://github.com/plantuml/wmf
The Java generated code is pretty well commented.

Maybe you could also convert/translate the following file:
https://github.com/papnkukn/wmf/blob/master/sample/Program.cs
and add it to the project.

Regards,
commented Aug 1, 2018 by nAlAz117 (240 points)
Program.java is here
https://www56.zippyshare.com/v/QmV1GNAc/file.html
Best wisches
commented May 7, 2019 by joe (100 points)
I got "File has expired and does not exist anymore on this server",  any other place could find it?
...