Annotate PDF from Net


Download Free Trial

About GroupDocs.Annotation for Net API

GroupDocs.Annotation for Net API is a library that allows you to add annotations to PDF, Word and other documents on Mac, Windows or Ubuntu. GroupDocs.Annotation for Net is a native Net API for managing annotations with comprehensive support for creating, adding, editing, deleting, extracting and exporting annotations from images and various other documents. The full list of supported document formats you could see on this page. This library allows you to work not only with PDF document but also with many other types documents such as Word, Excel, PowerPoint, Outlook emails, Visio, Adobe, OpenDocument, OpenOffice, Photoshop, AutoCad and many others. The GroupDocs.Annotation for Net API allows you to create and add new notes, edit annotations, extract comments, annotations, and remove them from documents. The library supports 13 different annotation types, including Text, Polyline, Area, Underline, Point, Watermark, Arrow, Ellipse, Text Replacement, Distance, Text Field, Resource Redaction in PDF, HTML, Microsoft Word documents, spreadsheets, diagrams, presentations, drawings, images and many other file formats. The example (please see below) demonstrates working with PDF document, in this example you could see the main steps of how to work with GroupDocs.Annotation: Setup a license, open a document you want to work with, creating an annotation, adding data objects to set annotation properties according to your requirements and saving the result to the needed place. Also you could have a look more detailed on the supported features on our github page, or in our product documentation.

Steps to Add Annotations to PDF in Net

GroupDocs.Annotation makes it easy for Net developers to add various annotation types to PDF files within any Net-based application by implementing a few easy steps.

  • Create Reply objects with comment and date.
  • Create AreaAnnotation object, set area options and add replies.
  • Create Annotator object and add area annotation.
  • Save output file.

System Requirements

GroupDocs.Annotation for Net APIs are supported on all major platforms and operating systems. Before executing the code below, please make sure that you have the following prerequisites installed on your system.

  • Operating Systems: Microsoft Windows, Linux, MacOS
  • Development Environments: Visual Studio, Xamarin, MonoDevelop
  • Frameworks: .NET Framework, .NET Standard, .NET Core, Mono
  • Download the latest version of GroupDocs.Annotation for .NET from NuGet

Annotation preview and code sample

//Add text field annotation to the document from local disk
using (Annotator annotator = new Annotator("input.bmp"))
{
    TextFieldAnnotation textField = new TextFieldAnnotation
    {
        BackgroundColor = 65535,
        Box = new Rectangle(100, 100, 100, 100),
        CreatedOn = DateTime.Now,
        Text = "Some text",
        FontColor = 65535,
        FontSize = 12,
        Message = "This is text field annotation",
        Opacity = 0.7,
        PageNumber = 0,
        PenStyle = PenStyle.Dot,
        PenWidth = 3,
        FontFamily = "Arial",
        TextHorizontalAlignment = HorizontalAlignment.Center,
        Replies = new List
        {
            new Reply
            {
                Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
                Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    };
    annotator.Add(textField);
    annotator.Save("result.bmp");
}

Annotation preview image

Steps to Remove Annotations from PDF in Net

GroupDocs.Annotation makes it easier for Net developers to remove annotation details from PDF files within any Net-based application by implementing a few easy steps.

  • Create Reply objects with comment and date.
  • Instantiate SaveOptions object and set AnnotationTypes = AnnotationType.None.
  • Call save method with resultant document path or stream and SaveOptions object.

// 1- How to remove annotation from document using annotation index

using (Annotator annotator = new Annotator("result.bmp"))
{
    annotator.Remove(0);
    annotator.Save("removed.bmp");
}

// 2- How to remove annotation from document using annotation object

using (Annotator annotator = new Annotator("result.bmp"))
{
    var tmp = annotator.Get();
    annotator.Remove(tmp[0]);
    annotator.Save("removed.bmp");
}

// 3- How to remove some annotations from document using list of ID’s

using (Annotator annotator = new Annotator("result.bmp"))
{
    var idList = new List{1, 2, 3};
    annotator.Remove(idList);
    annotator.Save("removed.bmp");
}

// 4- How to remove some annotations from document using list of annotations

using (Annotator annotator = new Annotator("result.bmp"))
{
    var tmp = annotator.Get();
    annotator.Remove(tmp);
    annotator.Save("removed.bmp");
}

Steps to Edit Annotations from PDF in Net

GroupDocs.Annotation makes it easier for Net developers to update various annotation properties from PDF files within any Net-based application by implementing a few easy steps.

  • Instantiate Annotator object with input document path or stream with instantiated LoadOptions with ImportAnnotations = true.
  • Create some AnnotationBase implementation and set Id of existed annotation (if annotation with that Id not found, nothing will be changed) or path list of annotations (all existed annotations will be removed).
  • Call update method of Annotator object with passed annotations.
  • Call save method with resultant document path or stream and SaveOptions object.

// open annotated document
using (Annotator annotator = new Annotator("result.bmp"))
{
    //assuming we are going to change some properties of existing annotation
        AreaAnnotation updated = new AreaAnnotation
            {
                    // It's important to set existed annotation Id
                    Id = 1,
                    BackgroundColor = 255,
                    Box = new Rectangle(0, 0, 50, 200),
                    CreatedOn = DateTime.Now,
                    Message = "This is updated annotation",
                    Replies = new List
                    {
                        new Reply
                        {
                            Comment = "Updated first comment",
                            RepliedOn = DateTime.Now
                        },
                        new Reply
                        {
                            Comment = "Updated second comment",
                            RepliedOn = DateTime.Now
                        }
                    }
                };
        // update annotation
        annotator.Update(updated);
        annotator.Save("result.bmp");
}

Steps to Extract Annotations from PDF in Net

GroupDocs.Annotation makes it easy for Net developers to annotate documents and extract annotation information from PDF files within any Net-based application by implementing a few easy steps.

  • Create Reply objects with comment and date.
  • Instantiate LoadOptions object and call SetImportAnnotations with true argument.
  • Define variable with type List.
  • Call get method and return result to variable above.

// for using this example input file ("annotated.bmp") must be with annotations
using (Annotator annotator = new Annotator("annotated.bmp"))
{
    List annotations = annotator.Get();
    XmlSerializer formatter = new XmlSerializer(typeof(List));
    using (FileStream fs = new FileStream("annotations.xml", FileMode.Create))
    {
        fs.SetLength(0);
        formatter.Serialize(fs, annotations);
    }
}

Live Demos to Add, Remove, Edit, Extract Annotations to Documents and Images

Add, remove, edit and extract annotations to PDF file right now by visiting GroupDocs.Annotation Live Demos website. The live demo has the following benefits

No need to download API

No need to write any code

Just upload the source file

Get download link to save the file

About PDF File Format

Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. PDF files can be opened in Adobe Acrobat Reader/Writer as well in most modern browsers like Chrome, Safari, Firefox via extensions/plug-ins. Most of the commercially available software suites also offer conversion of their documents to PDF file format without the requirement of any additional software component. Thus, PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.

Read More About PDF File Format

Working with Other Popular Document Formats

Update annotation properties from some of the popular file formats as stated below.

Annotate PDF document

(Adobe Portable Document Format)

Annotate DOC document

(Microsoft Word Document)

Annotate DOCM document

(Microsoft Word Macro-Enabled Document)

Annotate DOCX document

(Microsoft Word Open XML Document)

Annotate DOT document

(Microsoft Word Document Template)

Annotate DOTX document

(Word Open XML Document Template)

Annotate RTF document

(Rich Text Document)

Annotate ODT document

(Open Document Text)

Annotate XLS document

(Microsoft Excel Binary File Format)

Annotate XLSX document

(Microsoft Excel Open XML Spreadsheet)

Annotate XLSM document

(Microsoft Excel Macro-Enabled Spreadsheet)

Annotate XLSB document

(Microsoft Excel Binary Worksheet)

Annotate ODS document

(Open Document Spreadsheet)

Annotate PPT document

(PowerPoint Presentation)

Annotate PPTX document

(PowerPoint Open XML Presentation)

Annotate PPSX document

(PowerPoint Open XML Slide Show)

Annotate POTM document

(Microsoft PowerPoint Template)

Annotate PPTM document

(Microsoft PowerPoint Presentation)

Annotate PPS document

(Microsoft PowerPoint 97-2003 Slide Show)

Annotate ODP document

(OpenDocument Presentation)

Annotate HTML document

(HyperText Markup Language)

Annotate TIFF document

(Tagged Image File Format)

Annotate PNG document

(Portable Network Graphic)

Annotate EML document

(E-mail Message)

Annotate MSG document

(Microsoft Outlook E-mail Message)

Annotate VSD document

(Microsoft Visio 2003-2010 Drawing)

Annotate VSDX document

(Microsoft Visio Drawing)

Annotate VSS document

(Microsoft Visio 2003-2010 Stencil)

Annotate VST document

(Microsoft Visio 2013 Stencil)

Annotate DWG document

(Autodesk Design Data Formats)

Annotate DXF document

(AutoCAD Drawing Interchange)

Annotate DCM document

(Digital Imaging and Communications in Medicine)

Annotate WMF document

(Windows Metafile)

Annotate EMF document

(Enhanced Metafile Format)

Back to top
 English