Programmatically Accept or Reject Tracked Changes in Word

Before a business contract is signed, the two parties involved may have modified the document several times so as the both side can reach to an agreement. In order to know who’re changing what in your Word document, you can turn on Track Changes, and Accept or Reject the changes to get the tracked changes out of the document.

This article provides an easy solution in C# to accept or reject the tracked changes. Check below code snippets:

using Spire.Doc;
using Spire.Doc.Documents;

namespace AcceptOrRejectChanges
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.docx");

            Section sec = doc.Sections[0];
            Paragraph para = sec.Paragraphs[0];

            //accept changes
            para.Document.AcceptChanges();

            ////reject changes 
            //para.Document.RejectChanges();

            doc.SaveToFile("result.docx", FileFormat.Docx);
        }
    }

Result

2016-08-30_150234

How to Programmatically Mark up Text in an Existing PDF Document in C#

Users often face the situation that you may need to emphasize the most important information from all text on a PDF page. Highlight text is such a functionality which allow users to give prominence to key words or sentence. In this tip, I will introduce how to mark up text in an existing PDF document programmatically in C#.

This scenario depends on .NET PDF component.  Please download it and add Spire.Pdf.dll as reference in your project. Following code snippets demonstrate how to accomplish this task using the classes provided by this component.

Step 1: Load the sample PDF document.

PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");
PdfPageBase page = doc.Pages[0];

Step 2: Find the text (words or sentence) that you want to mark up.

PdfTextFind ptf = page.FindText("Highlight text").Finds[0];

Step 3: Create a Markup Annotation based on the text.

Font font = ptf.Font;
string markupText = "Higlight text";
PdfTextMarkupAnnotation annotation = new PdfTextMarkupAnnotation("Adminstrator", "Text Markup Annotation", markupText, ptf.Position, new PdfTrueTypeFont(font));
annotation.Border = new PdfAnnotationBorder(0.75f);
annotation.TextMarkupColor = Color.Yellow;

Step 4: Add the annotation to PDF page.

page.AnnotationsWidget.Add(annotation);
doc.SaveToFile("Markup.pdf", FileFormat.PDF);

 Screenshot of Result

gorge_636052500447758198_2016-07-26_151655