Edit PDF in Java
Use Aspose.Slides for Java to edit PDF files in Java applications.
Edit PDF in Java
Using
Aspose.Slides for Java
, you can edit a PDF file by adding a text shape and saving the result with SaveFormat.Pdf.
Java code for editing PDF
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();
}Edit PDF using Aspose.Slides
Aspose.Slides for 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.
How to edit PDF in Java
- Install Aspose.Slides for Java.
- Add the library as a reference in your project.
- Create a
Presentationinstance and import the sourcePDFcontent. - Access the slide you want to edit.
- Add a text shape with
addAutoShapeandsetText. - Save the edited file with
SaveFormat.Pdf.
Built with Aspose.Slides
Edit PPTX Files Online
The free Aspose.Slides Editor app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own PPTX files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides handles your files before you write code.
- Upload your PPTX files and edit them instantly.
- Save and download the edited file.
Edit other files
You can also edit files in other formats.