使用 Aspose.Total for Java ,您可以在任何 Java J2SE、J2EE、J2ME 应用程序中轻松地将 MD 转换为 POTM。首先,通过使用 Aspose.PDF for Java ,您可以将 MD 导出为 PPTX。之后,通过使用 Aspose.Slides for Java PowerPoint Processing API,您可以将 PPTX 转换为 POTM。
Java API 将 MD 转换为 POTM
- 用 Document 类打开MD文件
- 使用 save 方法将 MD 转换为 PPTX
- 用 Presentation 类加载PPTX文档
- 使用
save
方法将文档保存为 POTM 格式并设置
Potm
作为 SaveFormat
Document document = new Document("template.md"); | |
// save MD 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 Ppt format | |
presentation.save("output.ppt", SaveFormat.Ppt); |
通过 Java 打开加密的 MD 文件
加载 MD 文件格式时,您的文档可能受密码保护。 Aspose.PDF for Java 也允许您打开加密文档。为了打开加密文件,您可以初始化[Document]的新实例( https://reference.aspose.com/pdf/java/com.aspose.pdf/Document#Document-java.lang.String-java.lang.String- ) 类并将文件名和密码作为参数传递。
// open MD document
Document doc = new Document("input.md", "Your@Password");
// save MD as PPTX format
document.save("PptxOutput.pptx", SaveFormat.Pptx);
通过 Java 保存具有预定义视图类型的 POTM 文件
将 MD 转换为 POTM 后,您还可以为演示文稿添加预定义的视图类型。 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 Potm format
presentation.save("output.potm", SaveFormat.Potm);