easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

RemoveAttachedFiles Method

Removes all non-annotation type of file attachments from a PDF file.

Sub RemoveAttachedFiles(InputFileName As String, OutputFileName As String)

void RemoveAttachedFiles(string InputFileName, string OutputFileName)

void RemoveAttachedFiles(String InputFileName, String OutputFileName) throws PDFProcessorException


Return Values



This function can be used in conjunction with AttachFilesBatch to edit portfolio PDF files. Portfolios are multimedia-rich documents that encapsulate other documents. Given a sample portfolio PDF, RemoveAttachedFiles can be used to create an empty portfolio of the same style. As a second step, AttachFilesBatch is used to populate the blank portfolio with new content.

Make sure to set OptimizeAfterEachProcess to True in order to have all the original content permanently removed from the PDF. The function works without that, but your final output would carry the load from the original content, which not only increases the PDF file size unnecessarily, but could also cause copyright issues.

Example Usage (VB, ASP)

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")
' Make sure to permanently destroy unused content
oProcessor.OptimizeAfterEachProcess = True

' Remove all existing attachments
oProcessor.RemoveAttachedFiles "C:\test\sample.pdf", "C:\test\empty.pdf"

oProcessor.OptimizeAfterEachProcess = False

' Replace them with a list of new attachments
Dim AttachFileNames(0 To 2) As String
AttachFileNames(0) = "C:\test\attachment0001.pdf"
AttachFileNames(1) = "C:\test\attachment0002.pdf"
AttachFileNames(2) = "C:\test\attachment0003.pdf"
Dim Descriptions(0 To 2) As String
Descriptions(0) = "1st attachment"
Descriptions(1) = "2nd attachment"
Descriptions(2) = "3rd attachment"
oProcessor.AttachFilesBatch "C:\test\empty.pdf", _
                      "C:\test\output.pdf", _
                      AttachFileNames, _

Example Usage (C#)

PDFProcessor oProcessor = new PDFProcessor();

// Make sure to permanently destroy unused content
oProcessor.OptimizeAfterEachProcess = true;

// Remove all existing attachments
oProcessor.RemoveAttachedFiles(@"C:\test\sample.pdf", @"C:\test\empty.pdf");

oProcessor.OptimizeAfterEachProcess = false;

// Replace them with a list of new attachments
                      new string[] { @"c:\test\attachment0001.jpg", @"c:\test\attachment0002.doc", @"c:\test\attachment0003.pdf" },
                      new string[] { "1st attachment", "2nd attachment", "3rd attachment");