Generate Marked Content in C# and .NET PDFs

Marked content refers to PDF content which is either adjacent (if Mark Type is Point) or surrounded by (if Mark Type PdfContentMark Element Start and End).

The PdfContentMark element specifies a tag that indicates the role or importance of the marked content and optionally specifies the properties of the marked content.

In the following example, you can learn how to mark geometric content, which is a visual representation of specific Unicode content.

Complete code

using System;
using System.IO;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;
using SautinSoft.Pdf.Content.Marked;
using SautinSoft.Pdf.Objects;

namespace Sample
    class Sample
        /// <summary>
        /// Create PDF marked content.
        /// </summary>
        /// <remarks>
        /// Details:
        /// </remarks>
        static void Main(string[] args)
            // Before starting this example, please get a free 30-day trial key:

            // Apply the key here:
            // PdfDocument.SetLicense("...");

            using (var document = new PdfDocument())
                var page = document.Pages.Add();

                // Surround the path with the marked content start and marked content end elements.
                var markStart = page.Content.Elements.AddMarkStart(new PdfContentMarkTag(PdfContentMarkTagRole.Span));

                var markedProperties = markStart.GetEditableProperties().GetDictionary();

                // Add the path that is a visual representation of the letter 'H'.
                var path = page.Content.Elements.AddPath()
                    .BeginSubpath(100, 600).LineTo(100, 800)
                    .BeginSubpath(100, 700).LineTo(200, 700)
                    .BeginSubpath(200, 600).LineTo(200, 800);

                var format = path.Format;
                format.Stroke.IsApplied = true;
                format.Stroke.Width = 10;



            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("MarkedContent.pdf") { UseShellExecute = true });


If you need a new code example or have a question: email us at or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.