ByteScout PDF SDK - C# - Add Text Annotations in PDF - ByteScout

ByteScout PDF SDK – C# – Add Text Annotations in PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Add Text Annotations in PDF

How to add text annotations in PDF in C# with ByteScout PDF SDK

The tutorial shows how to add text annotations in PDF in C#

The sample source codes on this page shows how to add text annotations in PDF in C#. ByteScout PDF SDK: the pdf library that can create, update and modify PDF files. Supports text with fonts and style selections, layers, form fields, drawing lines and objects, automatic tables, images. Can be used to create and fill pdf forms. It can add text annotations in PDF in C#.

The SDK samples like this one below explain how to quickly make your application do add text annotations in PDF in C# with the help of ByteScout PDF SDK. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Enjoy writing a code with ready-to-use sample codes in C#.

Trial version of ByteScout PDF SDK can be downloaded for free from our website. It also includes source code samples for C# and other programming languages.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System.Diagnostics; using Bytescout.PDF; namespace TextAnnotationExample { /// <summary> /// This example demonstrates how to add a text annotation. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); // Add collapsed annotation (shown as a tooltip when mouse is over the icon) TextAnnotation collapsedAnnotation = new TextAnnotation(20, 20); collapsedAnnotation.Color = new ColorRGB(255, 255, 0); collapsedAnnotation.Icon = TextAnnotationIcon.Comment; collapsedAnnotation.Author = "Mr. Important"; collapsedAnnotation.Contents = "The quick brown fox jumps over the lazy dog."; page.Annotations.Add(collapsedAnnotation); // Add expanded annotation TextAnnotation expandedAnnotation = new TextAnnotation(20, 50); expandedAnnotation.Color = new ColorRGB(255, 0, 0); expandedAnnotation.Icon = TextAnnotationIcon.Note; expandedAnnotation.Open = true; expandedAnnotation.Author = "John Doe"; expandedAnnotation.Contents = "The quick brown fox jumps over the lazy dog."; page.Annotations.Add(expandedAnnotation); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next