Work with Attachments in PDF via Java
How to Get, Add, Save, and Delete Attachments from PDF programmatically with Java
How to Manage Attachments Using Java Library
In order to add Attachments, we’ll use Aspose.PDF for Java API which is a feature-rich, powerful and easy to use conversion API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
Work with Attachments in PDF via Java
You need Aspose.PDF for Java to try the code in your environment.
- Create a new Java project.
- Add a reference to Aspose.PDF DLL.
- Create a Document object.
- Create a FileSpecification object with the file you are adding, and file description.
- Add the FileSpecification object to the Document object’s EmbeddedFiles collection, with the collection’s Add method
- Save the PDF file.