// This code is part of GrapeCity Documents for PDF samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
using System;
using System.IO;
using System.Drawing;
using System.Text;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Pdf.AcroForms;

namespace GcPdfWeb.Samples
    // This example shows how to find and delete all occurrences of a text string in a PDF.
    public class DeleteText
        public void CreatePDF(Stream stream)
            var doc = new GcPdfDocument();
            using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "TimeSheet.pdf"));

            // Delete dates and times using regex pattern:
            var ftps = new FindTextParams(@"\d+/\d+/\d+|\d+:\d+| am| pm", false, false, 72, 72, false, true);
            doc.DeleteText(ftps, GrapeCity.Documents.Pdf.TextMap.DeleteTextMode.PreserveSpace);

            // For reference, append the original PDF:
            Common.Util.AddNote("For reference, the following page contains a copy of the original unmodified PDF.", doc.NewPage());
            var docOrig = new GcPdfDocument();

            // Done: