The moose likes Other Open Source Projects and the fly likes Conversion EPS to SWF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Conversion EPS to SWF" Watch "Conversion EPS to SWF" New topic

Conversion EPS to SWF

Prav Chau
Ranch Hand

Joined: Jul 17, 2007
Posts: 59
Is there a open source to convert EPS file to SWF file though java.

Prav Chau
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
EPS is a static format for text and/or images. What would converting it to a dynamic format like SWF accomplish?
Prav Chau
Ranch Hand

Joined: Jul 17, 2007
Posts: 59
Basically there are couple of things which happens after the EPS is converted into SWF. So first thing is Conversion of EPS to SWF through Java.
Robert Stanfield

Joined: Sep 22, 2009
Posts: 1
I recently had to solve this problem. I tested several products such as ps-to-image which converted the EPS to EMF. Then ps-to-image to convert the EMF to SWF. It seemed OK until with the example images they supply with the trial version. But when I used it with a clients EPS the quality was very poor. So I ended up using GhostScript to convert the EPS to PDF then used SWFTools PDF2SWF converter to convert the PDF to SWF and the results were fantastic. The only problem was the final SWF had a white box on layer 1 so I removed that using a SWF library in c#. You could do the same in with a JAVA SWF library. It just removed the 4th and 4th Tags in the compiled SWF ald I have a perfect vector SWF that was eactly like the EPS vector image.

Here is example code I used in C#

[DllImport("gsdll32.dll", EntryPoint = "gsapi_new_instance")]
private static extern int gsapi_new_instance(out IntPtr pinstance,IntPtr caller_handle);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")]
private static extern int gsapi_init_with_args(IntPtr instance, int argc, string[] argv);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_exit")]
private static extern int gsapi_exit(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_delete_instance")]
private static extern void gsapi_delete_instance(IntPtr instance);

gsargv[0] = "ps2pdf"; /* actual value doesn't matter */
gsargv[1] = "-dCompatibilityLevel=1.4";
gsargv[2] = "-q";
gsargv[3] = "-dNOPAUSE";
gsargv[4] = "-dBATCH";
gsargv[5] = "-dSAFER";
gsargv[6] = "-dEPSCrop";
gsargv[7] = "-sDEVICE=pdfwrite";
gsargv[8] = "-sOutputFile=myPDF.pdf";
gsargv[9] = "-c";
gsargv[10] = ".setpdfwrite";
gsargv[11] = "-f";
gsargv[12] = "myEPS.eps";
gsargc = gsargv.Count();

code = gsapi_new_instance(out gsInstancePtr, IntPtr.Zero);
if (code < 0)
LogError("Error: Could not get Ghostscript instance.");
code = gsapi_init_with_args(gsInstancePtr, gsargc, gsargv);
if (code < 0)
LogError("Error: Could not create PDF file from " + eps + ".");
code1 = gsapi_exit(gsInstancePtr);

run a command "pdf2swf myPDF.pdf -o mySWF.swf

SwfReader swfReader = new SwfReader(this.tmpSWFFile);
Swf swf = swfReader.ReadSwf();
BaseTagCollection tags = swf.Tags;
SwfWriter writer = new SwfWriter(this.outFile);
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi Robert and welcome to Javaranch!

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: Conversion EPS to SWF
It's not a secret anymore!