PPTX DOCX XLSX PDF ODP
Aspose.PDF  for Java
PDF

Remove Attachments from PDF document via Java

Delete Attachments from PDF programmatically with Java.

How to remove Attachments Using Java Library

In order to remove 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.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
    </repository>
    

 

Dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-pdf</artifactId>
    <version>version of aspose-pdf API</version>
    <classifier>jdk17</classifier>
    </dependency>
    

 

Remove Attachments from PDF via Java

You need Aspose.PDF for Java to try the code in your environment.

  1. Open existing PDF.
  2. Delete all attachments.
  3. Save the result.

System Requirements

Aspose.PDF for Java is supported on all major operating systems. Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Development environment like Eclipse or IntelliJ IDEA.
  • Aspose.PDF for Java library referenced in your project.
 

Delete Attachment from PDF document.


    public static void DeleteAllAttachmentsFromPDF(){
    // Open a document
    Document pdfDocument = new Document(_dataDir+"input.pdf");
    // Delete all attachments
    pdfDocument.getEmbeddedFiles().delete();
    // Save the updated file
    pdfDocument.save("output.pdf");

      }
 

About Aspose.PDF for Java API

A PDF Processing Library to create cross-platform applications with the ability to generate, modify, convert, render, secure and print documents without using Adobe Acrobat. It supports converting various file formats into PDF including HTML and converting PDF documents into various output formats. Developers can easily render all HTML content in a single Page PDF as well as convert HTML files with SVG graphic tags to Tagged PDF files. .NET PDF API offers compression, table creation, graph & image functions, hyperlinks, stamp and watermarking tasks, extended security controls & custom font handling.