Add Attachments to PDF via Java
Add Attachments to PDF document. Use Aspose.PDF for Java to modify PDF files programmatically
How to Add 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.
Add Attachments in PDF File 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.