Convert TXT to ODP via Java or Online App

TXT to ODP conversion by using on premise Java API within any Java J2SE, J2EE, J2ME applications without using Microsoft® PowerPoint or Word

TXT Conversion via Python TXT Conversion via C# .NET TXT Conversion via C++ TXT Conversion in Android Apps

 

Developers often need to convert TXT files to ODP programmatically. Fortunately, this process can be automated with the help of the File Automation Java libraries Aspose.Total for Java . This library provides a few simple steps to render the TXT file into ODP.

The first step is to load the TXT file using Aspose.Words for Java . This library allows you to convert the TXT file into HTML. After that, you can use the powerful PowerPoint manipulation Java API Aspose.Slides for Java to create a new Presentation. This library allows you to write HTML content into the Presentation and save it as ODP.

The File Automation Java libraries Aspose.Total for Java makes it easy to automate the process of converting TXT files to ODP. With the help of Aspose.Words for Java and Aspose.Slides for Java , you can quickly and easily convert your TXT file into ODP. All you need to do is load the TXT file, convert it to HTML, create a new Presentation, write HTML content in it, and save it as ODP. With the help of these libraries, you can automate the process of converting TXT files to ODP in a few simple steps.

How to Convert TXT to ODP via Java

  1. Open TXT file using Document class
  2. Convert TXT file to HTML by using save method
  3. Initialize a new Presentation object
  4. Extract content from HTML file using BufferedReader and write the content in your presentation file
  5. Save the document to ODP using save method

TXT File Conversion in Java

For TXT to ODP file conversion, you can easily use Aspose.Total for Java directly from a Maven based project and include libraries in your pom.xml.

Alternatively, you can get a ZIP file from downloads .

// 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);

Free Online Converter for TXT to ODP

Convert TXT to ODP with Watermark via Java

Using the API, you can also perform TXT file to ODP conversion with watermark. In order to add a watermark to your ODP document, you can first export TXT to HTML and write HTML content in Presentation object. After that to add a watermark, you can add text using addTextFrame, set all the relevant options like color, fillType and more and can save the document to ODP.

// 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);

FAQ

  • How can I convert TXT to ODP Online?
    The above-integrated online app allows you to convert TXT files to ODP. To get started, simply drag and drop or click inside the white area to import your TXT file. Once your file is uploaded, click the "Convert" button. After the TXT to ODP conversion process is complete, you can download your converted file with just one click.
  • How long does it take to convert TXT?
    This online TXT converter works quickly, but its speed depends primarily on the size of the TXT file you are converting. Smaller TXT files can be converted to ODP in just a few seconds. If you have integrated the conversion code into your Java application, the speed of the conversion process will depend on how well you have optimized your application.
  • Is it safe to convert TXT to ODP using free Aspose.Total converter?
    Of course! After the conversion is complete, the download link for your ODP file will be available instantly. Your uploaded files will be deleted after 24 hours, and the download links will no longer work after that period. Your files are safe, and no one has access to them. The integrated app is mainly free for testing purposes, so you can verify the results before integrating the code.
  • What browser should I use to convert TXT?
    You can perform this online conversion using any modern browser such as Google Chrome, Firefox, Opera, or Safari. However, if you are building a desktop application, the Aspose.Total TXT Conversion API offers a smooth experience.

Explore TXT Conversion Options with Java

Convert TXT to POT (Microsoft PowerPoint Template Files)
Convert TXT to POTM (Microsoft PowerPoint Template File)
Convert TXT to POTX (Microsoft PowerPoint Template Presentation)
Convert TXT to PPTX (Open XML presentation Format)
Convert TXT to PPS (PowerPoint Slide Show)
Convert TXT to PPSM (Macro-enabled Slide Show)
Convert TXT to PPSX (PowerPoint Slide Show)
Convert TXT to PPT (PowerPoint Presentation)
Convert TXT to PPTM (Macro-enabled Presentation File)
Convert TXT to PPTX (Open XML presentation Format)