您是一名希望为您的应用程序添加文档转换功能的 Android 开发人员吗? Aspose.Total for Android via Java 文件格式自动化库可以帮助您在 Android 应用程序中自动化文档转换过程。为了将 DOCM 文件转换为 PPTM,您可以首先使用文档操作 API Aspose.Words for Android via Java 将 DOCM 文件格式转换为 HTML。之后使用 PowerPoint API Aspose.Slides for Android Java ,您可以创建一个新的演示文稿,在其中写入 HTML 内容,并将其另存为耗氧量。
如何在 Android 中将 DOCM 转换为 PPTM
- 使用 Document 类打开 DOCM 文件
- 使用 [save]( https://reference.aspose.com/words/java/com.aspose.words/Document#save(java.lang.String,com.aspose.words.SaveOptions) 将 DOCM 文件转换为 HTML )) 方法
- 始化一个新的 Presentation 对象
- 使用 BufferedReader 从 HTML 文件中提取内容并将内容写入您的演示文件
- 使用 save 方法将文档保存到 PPTM
// supports DOC, DOCX, DOT, DOTM, DOTX, FLATOPC, ODT, OTT, RTF, TXT, WORDML, DOCM input file formats | |
// load DOC file with an instance of Document | |
Document document = new Document("template.doc"); | |
// save the document in HTML file format | |
document.save("HtmlOutput.html",SaveFormat.HTML); | |
// create a new presentation | |
Presentation pres = new Presentation(); | |
// access the default first slide of presentation | |
ISlide slide = pres.getSlides().get_Item(0); | |
// add the AutoShape to accommodate the HTML content | |
IAutoShape ashape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 10, 10, | |
(float) pres.getSlideSize().getSize().getWidth(), | |
(float) pres.getSlideSize().getSize().getHeight()); | |
ashape.getFillFormat().setFillType(FillType.NoFill); | |
// add text frame to the shape | |
ashape.addTextFrame(""); | |
// clear all paragraphs in added text frame | |
ashape.getTextFrame().getParagraphs().clear(); | |
// initialize StringBuilder to read Html | |
StringBuilder contents = new StringBuilder(); | |
// load HTML file by using BufferedReader | |
BufferedReader reader = new BufferedReader(new FileReader(new File("HtmlOutput.html"))); | |
String text = null; | |
// repeat until all lines are read | |
while ((text = reader.readLine()) != null) { | |
contents.append(text).append(System.getProperty("line.separator")); | |
} | |
reader.close(); | |
// add HTML content in text frame | |
ashape.getTextFrame().getParagraphs().addFromHtml(content); | |
// supports POTM, POT, POTX, PPSM, PPS, PPSX, PPTM, PPT, PPTX, ODP output file formats. | |
// save presentation as Pptx | |
pres.save("output.pptx", com.aspose.slides.SaveFormat.Pptx); |
免费的 DOCM 到 PPTM 在线转换器
通过 Java 在 Android 中将受保护的 DOCM 转换为 PPTM
您还可以在 Android 应用程序中将受密码保护的 DOCM 转换为 PPTM。如果您输入的 DOCM 文档受密码保护,则您无法在不使用密码的情况下将其转换为 PPTM 格式。为了打开加密文档,您可以在 LoadOptions 对象中设置正确的密码并将其传递给 Document 构造函数。
// supports DOC, DOCX, DOT, DOTM, DOTX, FLATOPC, ODT, OTT, RTF, TXT, WORDML, DOCM input file formats | |
// load DOC file with an instance of Document | |
Document document = new Document("template.doc"); | |
// save the document in HTML file format | |
document.save("HtmlOutput.html",SaveFormat.HTML); | |
// create a new presentation | |
Presentation pres = new Presentation(); | |
// access the default first slide of presentation | |
ISlide slide = pres.getSlides().get_Item(0); | |
// add the AutoShape to accommodate the HTML content | |
IAutoShape ashape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 10, 10, | |
(float) pres.getSlideSize().getSize().getWidth(), | |
(float) pres.getSlideSize().getSize().getHeight()); | |
ashape.getFillFormat().setFillType(FillType.NoFill); | |
// add text frame to the shape | |
ashape.addTextFrame(""); | |
// clear all paragraphs in added text frame | |
ashape.getTextFrame().getParagraphs().clear(); | |
// initialize StringBuilder to read Html | |
StringBuilder contents = new StringBuilder(); | |
// load HTML file by using BufferedReader | |
BufferedReader reader = new BufferedReader(new FileReader(new File("HtmlOutput.html"))); | |
String text = null; | |
// repeat until all lines are read | |
while ((text = reader.readLine()) != null) { | |
contents.append(text).append(System.getProperty("line.separator")); | |
} | |
reader.close(); | |
// add HTML content in text frame | |
ashape.getTextFrame().getParagraphs().addFromHtml(content); | |
// add watermark | |
IAutoShape ashp = slide.getShapes() | |
.addAutoShape(ShapeType.Rectangle,50, 50, 500, 500); | |
ashp.addTextFrame("Watermark Text"); | |
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions() | |
.get_Item(0).getPortionFormat().getFillFormat() | |
.setFillType(FillType.Solid); | |
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions() | |
.get_Item(0).getPortionFormat().getFillFormat() | |
.getSolidFillColor().setColor(Color.GRAY); | |
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions() | |
.get_Item(0).getPortionFormat().setFontHeight(25); | |
// Change the line color of the rectangle to White | |
ashp.getShapeStyle().getLineColor().setColor(Color.WHITE); | |
ashp.getShapeStyle().setLineStyleIndex(LineStyle.ThinThin); | |
// Remove any fill formatting in the shape | |
ashp.getFillFormat().setFillType(FillType.NoFill); | |
ashp.setRotation(-45); | |
ashp.getAutoShapeLock().setSelectLocked(true); | |
ashp.getAutoShapeLock().setSizeLocked(true); | |
ashp.getAutoShapeLock().setTextLocked(true); | |
ashp.getAutoShapeLock().setPositionLocked(true); | |
ashp.getAutoShapeLock().setGroupingLocked(true); | |
// supports POTM, POT, POTX, PPSM, PPS, PPSX, PPTM, PPT, PPTX, ODP output file formats. | |
// save presentation as Pptx | |
pres.save("output.pptx", com.aspose.slides.SaveFormat.Pptx); |
经常问的问题
- 如何在线将 DOCM 转换为 PPTM?为了您的方便,上面集成了 DOCM 转换在线应用程序。要将 DOCM 文件转换为 PPTM,只需通过将 DOCM 文件拖放到白色区域或在该区域内单击以将其导入来添加 DOCM 文件。之后,单击“转换”按钮。 DOCM 到 PPTM 的转换完成后,您只需单击一下即可下载转换后的文件。
- 转换 DOCM 需要多长时间?此在线转换器的速度在很大程度上取决于您要转换的 DOCM 文件的大小。只需几秒钟即可将小型 DOCM 文件转换为 PPTM。但是,如果您已将转换代码集成到您的 Android App 应用程序中,则速度将取决于您针对转换过程优化应用程序的程度。
- 使用免费的 Aspose.Total 转换器将 DOCM 转换为 PPTM 是否安全?当然!转换后,您的 PPTM 文件的下载链接将立即可用。上传文件24小时后自动删除,下载链接失效。请放心,您的文件是安全的,因为没有其他人可以访问它们。我们的文件转换服务(包括 DOCM 文件)是完全安全的。此外,还提供了一个免费的应用程序用于测试目的,允许您在集成代码之前确认结果。
- 我应该使用什么浏览器来转换 DOCM?Google Chrome、Firefox、Opera 和 Safari 等现代网络浏览器与此在线转换工具兼容。但是,如果您在桌面应用程序上工作,建议使用 Aspose.Total DOCM Conversion API 以实现流畅的操作。