Edit HTML in Java

High-speed and cross-platform Java library for editing HTML using Java code

Edit HTML using Aspose.Slides

Aspose.Slides for Java is a powerful Java library used to manipulate and edit presentations, HTML documents, and other files. You can edit an HTML doc by adding a new line of text to it.

Edit HTML in Java

Using Aspose.Slides for Java , you can add a new line of text to an HTML document with just a few lines of code.

Java code for editing HTML


Presentation pres = new Presentation();
try {
    pres.getSlides().removeAt(0);
    FileInputStream htmlStream = new FileInputStream("page.html");
    try {
        pres.getSlides().addFromHtml(htmlStream);
    } finally {
        if (htmlStream != null) htmlStream.close();
    }

    ISlide slide = pres.getSlides().get_Item(0);
    IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 10, 10, 100, 50);
    shape.getTextFrame().setText("New text");

    pres.save("page.html", SaveFormat.Html5);
} catch(IOException e) {
} finally {
    if (pres != null) pres.dispose();
}

How to edit HTML in Java

  1. Install Aspose.Slides for Java. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the HTML document you want to edit.

  5. Add a new line of text.

  6. Save the changed HTML file.

Edit other files

You can also edit files in other formats