Delete Images from PDF File

[ ]

To delete an image from a PDF file:

  1. Create a Document object and open the input PDF file.
  2. Get the Page that holds the image from the Document object’s Pages collection.
  3. Images are held in the Images collection, found in the page’s Resources collection.
  4. Delete an image with the Images collection’s Delete method.
  5. Saved the output like using the Document object’s Save method.

The following code snippet shows how to delete an image from a PDF file.

// For complete examples and data files, please go to
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Images();

// Open document
Document pdfDocument = new Document(dataDir+ "DeleteImages.pdf");

// Delete a particular image

dataDir = dataDir + "DeleteImages_out.pdf";
// Save updated PDF file