Remove Images from PDF document via C#

Delete images from PDF document using Aspose.PDF for .NET Library

Remove Images from PDF Document Using C# Library

In order to remove Image from PDF, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for net platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF

Delete Images from PDF via C#


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

  1. Open existing PDF Document.
  2. Delete a particular image.
  3. Save updated PDF file.

Delete Images from Existing PDF File - C#

This sample code shows how to remove Images from PDF - C#


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

    // Delete a particular image
    pdfDocument.Pages[1].Resources.Images.Delete(1);

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