Why to Convert CGM to SWF?
CGM (Computer Graphics Metafile) is a vector graphics format used for storing and exchanging graphics data. It is widely used in the engineering and technical drawing fields. SWF (Small Web Format) is a vector file format used for multimedia, vector graphics and ActionScript. It is used for displaying interactive vector graphics and animations in web browsers. Therefore, it is necessary to convert CGM to SWF in order to make the graphics and animations viewable in web browsers.
How Aspose.Total Helps for CGM to SWF Conversion?
Aspose.Total for Android via Java is a suite of file format APIs that enables developers to create, edit, render, print and convert documents within Android applications. It includes APIs for manipulating PDF, Word, Excel, PowerPoint, Project, Visio, Email, Barcode, OCR and HTML formats. It also includes APIs for manipulating CGM and SWF formats.
Using Aspose.Total for Android via Java, you can easily integrate CGM to SWF conversion feature inside your Android applications. In the first step, you can export CGM to PPTX by using Aspose.PDF for Android via Java. After that, by using Aspose.Slides for Android via Java, you can convert PPTX to SWF. Both APIs come under Aspose.Total for Android via Java package.
Android API to Export CGM to SWF
- Open CGM file using Document class
- Convert CGM to PPTX by using save method
- Load PPTX document by using Presentation class
- Save the document to SWF format using
save
method and set
Swf
as SaveFormat
Get Started with Java File Format APIs
You can easily use Aspose.Total for Android via Java directly from Maven and install Aspose.PDF for Android via Java and Aspose.Slides for Android via Java in your applications.
Alternatively, you can get a ZIP file from downloads .
// load CGM file with an instance of Document class
Document document = new Document("template.cgm");
// save CGM as PPTX format
document.save("PptxOutput.pptx", SaveFormat.Pptx);
// instantiate a Presentation object that represents a PPTX file
Presentation presentation = new Presentation("PptxOutput.pptx");
// save the presentation as Swf format
presentation.save("output.swf", SaveFormat.Swf);
Open Password Protected CGM File in Android Apps
While loading CGM file format, your document might be password protected. Aspose.PDF for Android via Java allows you open encrypted documents as well. In order to open the encrypted file, you can initialize new instance of the Document class and pass filename and password as arguments.
// open CGM document
Document doc = new Document("input.cgm", "Your@Password");
// save CGM as PPTX format
document.save("PptxOutput.pptx", SaveFormat.Pptx);
Create Thumbnail Image of SWF File in Android Applications
After converting CGM to SWF, you can also create thumbnail images of your output document. By using rich in feature Aspose.Slides for Android via Java you can generate thumbnail images of the slides by creating and instance of the Presentation class. After that, you can obtain the reference of any desired slide by using its ID or index and get the thumbnail image of the referenced slide on a specified scale.
// instantiate a Presentation object that represents a SWF file
Presentation presentation = new Presentation("output.swf");
// access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// create a full scale image
BufferedImage image = sld.getThumbnail(1f, 1f);
// save the image to disk in PNG format
ImageIO.write(image, "PNG", new java.io.File("Thumbnail_out.png"));