XDoc.PDF
Features
Tech Specs
How-to C#
Pricing
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print Work with Other SDKs Barcode Read Barcode Create OCR Twain

C# PDF Text Editor Library
How to delete, remove text from PDF file using C# .net


How to Use C# Programming Demo Code to Delete Text from PDF File with .NET PDF Component










  • Professional PDF SDK library for adobe PDF text deletion in Visual Studio .NET framework program
  • Free evaluation components able to perform PDF text deletion function in both C#.NET WinForms and ASP.NET project
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Delete text from PDF file in preview without adobe PDF reader component installed in ASP.NET
  • C# class source code able to help users delete text characters at specified position from PDF in .NET console application
  • Able to pull text out of selected PDF page or all PDF document in .NET WinForms
  • Functionality to remove text format by modifying text font, size, color, etc
  • Other PDF edit functionalities, like add PDF text, add PDF text box and field


In document management system, users may have the need of deleting content from PDF document, like text characters. And RasterEdge .NET PDF SDK is such a qualified solution that allows C# programmers to integrate mature text deletion functionality into .NET projects. Basically, you can use robust APIs to select a PDF page, define the text character position, and remove it from PDF document.







Delete a character in a PDF page


//  open a document
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);
//  get a text manager from the document object
PDFTextMgr textMgr = PDFTextHandler.ExportPDFTextManager(doc);

//  get the first page from the document
int pageIndex = 0;
PDFPage page = (PDFPage)doc.GetPage(pageIndex);

//  select char at position (127F, 187F)
PointF cursor = new PointF(127F, 187F);
PDFTextCharacter aChar = textMgr.SelectChar(page, cursor);

//  delete a selected character
textMgr.DeleteChar(aChar);

//  output the new document
String outputFilePath = Program.RootPath + "\\" + "output.pdf";
doc.Save(outputFilePath);




Delete characters in a PDF page


//  open a document
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);
//  get a text manager from the document object
PDFTextMgr textMgr = PDFTextHandler.ExportPDFTextManager(doc);

//  get the first page from the document
int pageIndex = 0;
PDFPage page = (PDFPage)doc.GetPage(pageIndex);

//  extract all characters in the page
List<PDFTextCharacter> chars = textMgr.ExtractTextCharacter(page);

int cnt = 0;
//  delete a character every 3 characters
foreach (PDFTextCharacter aChar in chars)
{
    if (cnt % 3 == 0)
    {
        textMgr.DeleteChar(aChar);
    }
    cnt++;
}

//  output the new document
String outputFilePath = Program.RootPath + "\\" + "output.pdf";
doc.Save(outputFilePath);




Remove all characters in a page region


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

//  open document
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 3rd page
PDFPage page = (PDFPage)doc.GetPage(2);
//  set redact region
RectangleF region = new RectangleF(100F, 100F, 300F, 300F);

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

//  process redaction
PDFTextHandler.RedactText(page, region, options);
//  output file
doc.Save(outputFilePath);