# Edit PDF in Java

> Edit PDF files in Java. Use Aspose.Slides for Java to modify PDF content and save the edited file.

Source: https://products.aspose.com/slides/java/editor/pdf/
Updated: 2026-07-09



## Edit PDF using Aspose.Slides

[Aspose.Slides for Java](/slides/java/) is a Java API for working with presentation content. You can import a `PDF` file into a `Presentation`, add a text shape, and save the edited content as `PDF`.

## Edit PDF in Java

Using [Aspose.Slides for Java](/slides/java/), you can edit a `PDF` file by adding a text shape and saving the result with `SaveFormat.Pdf`.

### Java code for editing PDF

```java
Presentation presentation = new Presentation();
try {
    presentation.getSlides().removeAt(0);
    presentation.getSlides().addFromPdf("document.pdf");

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

    presentation.save("document.pdf", SaveFormat.Pdf);
} finally {
    presentation.dispose();
}
```

## How to edit PDF in Java

Install [Aspose.Slides for Java](https://docs.aspose.com/slides/java/installation/).

Add the library as a reference in your project.

Create a `Presentation` instance and import the source `PDF` content.

Access the slide you want to edit.

Add a text shape with `addAutoShape` and `setText`.

Save the edited file with `SaveFormat.Pdf`.

## Edit other files
