使用 Aspose.Total for Java ,您可以在任何 Java J2SE、J2EE、J2ME 应用程序中轻松地将 CGM 转换为 XAML。首先,通过使用 Aspose.PDF for Java ,您可以将 CGM 导出为 PPTX。之后,通过使用 Aspose.Slides for Java PowerPoint Processing API,您可以将 PPTX 转换为 XAML。
Java API 将 CGM 转换为 XAML
- 用 Document 类打开CGM文件
- 使用 save 方法将 CGM 转换为 PPTX
- 用 Presentation 类加载PPTX文档
- 使用
save
方法将文档保存为 XAML 格式并设置
Xaml
作为 SaveFormat
Document document = new Document("template.cgm"); | |
document.save("PptxOutput.pptx", SaveFormat.Pptx); | |
Presentation presentation = new Presentation("PptxOutput.pptx"); | |
presentation.save("output.xaml", SaveFormat.Xaml); |
通过 Java 打开加密的 CGM 文件
加载 CGM 文件格式时,您的文档可能受密码保护。 Aspose.PDF for Java 也允许您打开加密文档。为了打开加密文件,您可以初始化[Document]的新实例( https://reference.aspose.com/pdf/java/com.aspose.pdf/Document#Document-java.lang.String-java.lang.String- ) 类并将文件名和密码作为参数传递。
// open CGM document
Document doc = new Document("input.cgm", "Your@Password");
// save CGM as PPTX format
document.save("PptxOutput.pptx", SaveFormat.Pptx);
通过 Java 保存具有预定义视图类型的 XAML 文件
将 CGM 转换为 XAML 后,您还可以为演示文稿添加预定义的视图类型。 Aspose.Slides for Java 提供了一种工具来设置生成的演示文稿在通过 [ViewProperties](https:// /apireference.aspose.com/slides/java/com.aspose.slides/ViewProperties) 类。 setLastView 属性用于通过使用[ViewType](https:// /apireference.aspose.com/slides/java/com.aspose.slides/ViewType) 枚举器。
// instantiate a Presentation object that represents a PPTX file
Presentation presentation = new Presentation("PptxOutput.pptx");
// set view type
presentation.getViewProperties().setLastView((byte) ViewType.SlideMasterView);
// save the presentation as Xaml format
presentation.save("output.xaml", SaveFormat.Xaml);