Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion EPS to SWF

 
Prav Chau
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a open source to convert EPS file to SWF file though java.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently had to solve this problem. I tested several products such as www.verydoc.com ps-to-image which converted the EPS to EMF. Then www.verydoc.com 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);
gsapi_delete_instance(gsInstancePtr);

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


SwfReader swfReader = new SwfReader(this.tmpSWFFile);
Swf swf = swfReader.ReadSwf();
BaseTagCollection tags = swf.Tags;
swf.Tags.RemoveAt(4);
swf.Tags.RemoveAt(5);
SwfWriter writer = new SwfWriter(this.outFile);
writer.Write(swf);
writer.Close();
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robert and welcome to Javaranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic