ReplaceText2.cs
//
// 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
{
    // TBD:
    public class ReplaceText2
    {
        public void CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "gc-docs-data-sheet.pdf"));
            doc.Load(fs);

            // Replace:
            doc.ReplaceText(new FindTextParams(".NET Standard 2.0", false, true), ".NET 6");

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

            // Done:
            doc.Save(stream);
        }
    }
}