Creating a vector graphics image on the clipboard to export to MS Word

I am looking for a way to produce vector graphics for export via the system clipboard to MS Word or some other wordprocessor (as an enhanced metafile, for example).

I am creating mathematical graphs of functions (like f(x) = x^2) with cartesian coordinate axes, and presently the graphs print out with the lines and curves looking pretty jaggy (i.e. bitmapped).

Is there a "simple" solution, where I can just get a Graphics object from some package object and pass it to my paint methods to create a vector-graphics image that can then be passed to the system clipboard?

I don't need the images on the screen in my application/applet to be as smooth (jagless), though I suppose that would be cool too.

My biggest concern is that it looks smooth and professional when it is printed out on a printer.

Am I just dreaming?

Thanks!

[870 byte] By [MCCmathProfa] at [2007-11-26 16:26:42]
# 1

I realize I could use antialiasing to improve the image quality, but is there a way to generate a true emf(enhanced metafile) or some other vector graphic image that could be placed on the clipboard? For example, can the svg images I have read about be placed on the clipboard and pasted into WORD? Does anyone know how to do this?

If so, how could this be done? Any code or links would be very appreciated.

My goal is to generate high-quality printed mathematical graphs similar to those generated by Excel for example.

Thanks!

MCCmathProfa at 2007-7-8 22:50:50 > top of Java-index,Security,Cryptography...
# 2
It's likely that anything embedded in Word is a MS-COM object. The best way is probably to create a simple VB program, and send the data to VB. Have VB construct the COM object, and send that to the clipboard.
rkippena at 2007-7-8 22:50:50 > top of Java-index,Security,Cryptography...
# 3

That sounds possible, but though I have worked with both Java and VB, I have never considered communicating between the two.

Is that easy to do? Perhaps you could send me a link to some further explanation or some code examples?

Also, I have created emfs in VB before, but you need to actually execute the drawing commands in VB to do that.

Could I control the VB executing part from Java too?

On the other hand, my real goal here is to implement this copying to the clipboard in an applet, so I don't think VB would be as easy to use (or as portable) in that scenario. Perhaps it would work in a Java Web Start application though?

I want to be able to copy the best possible image quality (for printing) and I would love to have it produce these results in more than just the Windows platform, though I am looking into using Freehep's VectorGraphics package to copy an EMF to the clipboard and paste this into MS WORD. This will at least be a fully Java solution, but it may not be that portable. I plan to allow copying of the normal image to the clipboard as well, which probably should work fine on most platforms.

Any other options? Are there other useful Vector graphics formats that MS WORD would render as well as its favored EMF, but which may also work well on non-Microsoft platforms?

Thanks!

MCCmathProfa at 2007-7-8 22:50:50 > top of Java-index,Security,Cryptography...
# 4

You can communicate with VB in the following ways:

1) store the data in a file

start VB with a command line paramter pointing to the file

2) pass the data directly in the VB command line

or

3) use a Winsock control. there are lots of tutorials. I think the best is:

http://www.osix.net/modules/article/?id=25

also see the MSDN library:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mswnsk98/html/vbobjWinsockControl.asp

If you're not planning on editing the vector graphics in word, then i see little point in trying to paste it as such. I think word is notorious for pasting images and then changing the scale. If your image is too big, try scaling it down before you copy it to the clipboard. Don't let word rescale it, its image scaling algorithm is poor.

It would help to see an image of what your Java application shows vs. what happens when you paste it into word.

rkippena at 2007-7-8 22:50:50 > top of Java-index,Security,Cryptography...
# 5

Recently I had to do some work with producing high quality images in MS-Word.

The images I was dealing with typically measured 3 inches by 1 inch or there abouts. The trick I used was to create the image file so that the image dimensions were 3000 pixels by 1000 pixels. Then I saved the image as a PNG file, specifying the resolution of the image anywhere from 600 x 600 dpi to 1200 x 1200 dpi. This greatly improved the quality of the image.

MS-Paint can save as PNG, but it doesn't have resolution flag. I used Gimp to create the PNG file. Gimp allows you to specify the resolution of the image. Then when the image is pasted into MS-Word, Word looks at the resolution inside the PNG file.

rkippena at 2007-7-8 22:50:50 > top of Java-index,Security,Cryptography...