File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Conversion EPS to SWF" Watch "Conversion EPS to SWF" New topic
Author

Conversion EPS to SWF

Prav Chau
Ranch Hand

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


Prav Chau
SCJP, SCWCD, SCBCD, SCEA, http://pravinchaudhari.blogspot.com/
Ulf Dittmer
Marshal

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


Ping & DNS - my free Android networking tools app
Prav Chau
Ranch Hand

Joined: Jul 17, 2007
Posts: 58
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

Joined: Sep 22, 2009
Posts: 1
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Robert and welcome to Javaranch!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Conversion EPS to SWF