How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Image Editor Library
How to remove, delete, redact image from existing PDF file using C# .net


.NET PDF SDK Provides C# Demo Code for Deleting and Removing Image from PDF File Page







In this C# tutorial page, you will learn how to remove images from a PDF file using C# in .NET applications.

  • Remove all images in the PDF document
  • Remove images covered the page coordinates (X, Y)
  • Delete images from a page region
  • Remove all images from a specified PDF page
  • Redact an image in the page

How to read, extract PDF file images using C#

  1. Download XDoc.PDF Image Reader C# library
  2. Install PDF C# library to read, extract PDF images
  3. Step by Step Tutorial










  • A best C#.NET PDF image editor control able to delete images from adobe PDF document in Visual Studio .NET framework project
  • Free evaluation SDK library for PDF image deletion in .NET WinForms and ASP.NET program
  • Free C# PDF how-to pages: c# add text to existing pdf file, c# extract images from pdf, c# add png to pdf, find and replace text in pdf using c#, remove text from pdf c#, get coordinates of text in pdf c#.
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • C#.NET class source code are accessible for removing PDF pages in .NET console application
  • Support removing vector image, graphic picture, digital photo, scanned signature, logo, etc
  • Get all image objects and remove multiple or all images from PDF document
  • Delete and remove all image objects contained in a specific PDF page
  • Define position to remove a specified image from PDF document page






Remove all images in the PDF file using c#


This complete C# example shows how to extract all images and remove them all from the PDF document in C#.



String inputFilePath = Program.RootPath + "\\" + "3.pdf";
String outputFilePath = Program.RootPath + "\\" + "output.pdf";

//  open the document
PDFDocument doc = new PDFDocument(inputFilePath);
//  extract all images from the document
List<PDFImage> allImages = PDFImageHandler.ExtractImages(doc);
//  delete all images from the document
foreach (PDFImage image in allImages)
{
    PDFImageHandler.DeleteImage(doc, image);
}

//  output the new document
doc.Save(outputFilePath);




Remove all images from a page X, Y coordinate point using C#


XDoc.PDF SDK is using Window Coordinate System.
Points on the screen are described by x- and y-coordinate pairs. The x-coordinates increase to the right; y-coordinates increase from top to bottom. The origin (0,0) is the most left top point on the pdf page.



String inputFilePath = @"C:\1.pdf";
String outputFilePath = @"C:\output.pdf";

//  Open file and get the first page
PDFDocument doc = new PDFDocument(inputFilePath);
PDFPage page = (PDFPage)doc.GetPage(0);

//  Delete all images in the page position (100, 200). Unit: pixel (in 96 dpi)
PDFImageHandler.DeleteImages(page, new PointF(100, 200));

//  Save file
doc.Save(outputFilePath);




Remove images in the specified page region


For api: public RectangleF(float x, float y, float width, float height)
(x,y) is the Rectangle left top corner coordicate, width, height are the rectangle's width and height.



String inputFilePath = @"C:\1.pdf";
String outputFilePath = @"C:\output.pdf";

//  Open file and get the first page
PDFDocument doc = new PDFDocument(inputFilePath);
PDFPage page = (PDFPage)doc.GetPage(0);

//  Delete all images in the specified page area. Unit: pixel (in 96 dpi)
PDFImageHandler.DeleteImages(page, new RectangleF(50, 50, 90, 20));

//  Save file
doc.Save(outputFilePath);




Delete, remove all images from a pdf page using C#


String inputFilePath = @"C:\1.pdf";
String outputFilePath = @"C:\output.pdf";

//  Open file and get the first page
PDFDocument doc = new PDFDocument(inputFilePath);
PDFPage page = (PDFPage)doc.GetPage(0);

//  Delete all images in the page.
PDFImageHandler.DeleteImages(page);

//  Save file
doc.Save(outputFilePath);




Redact, delete an image in the page using c#


String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "output.pdf";

//  open document
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 1st page
PDFPage page = (PDFPage)doc.GetPage(0);

List<PDFImage> images = PDFImageHandler.ExtractImages(page);
if (images == null || images.Count == 0) return;

//  create redaction option
RedactionOptions options = new RedactionOptions();
options.AreaFillColor = Color.LightGray;

//  redact the image in the page
PDFImageHandler.RedactImage(page, images[0], options);
//  output file
doc.Save(outputFilePath);