Extract Attachments from PDF File

[ ]

One of the main category under the extraction capabilities of com.aspose.pdf.facades is the attachment extraction. This category provides a set of methods, which not only help extract the attachments but also provides the methods which can give you the attachment related information i.e. GetAttachmentInfo and GetAttachName methods provide attachment information and attachment name respectively. In order to extract and then get attachments we use ExtractAttachment and GetAttachment methods.

The following code snippet shows you how to use PdfExtractor methods:

  public static void ExtractAttachments() {
        PdfExtractor pdfExtractor = new PdfExtractor();
        pdfExtractor.bindPdf(_dataDir + "sample-attach.pdf");

        // Extract attachments

        // Get attachment names
        if (pdfExtractor.getAttachNames().size() > 0) {
            System.out.println("Extracting and storing...");
            // Get extracted attachments