DEV Community


Posted on

Export annotations and retrieve document pages using C# .NET Annotator API

Most recent monthly release of the .NET document annotator API allows applications developers to redeem document pages with or without the annotations, export specific annotation type and range of pages while annotating documents or images on .NET platform. Other highlights from version 18.12 of GroupDocs.Annotation for .NET are important enhancements such as adding text replacement for grouped shapes and a number of fixed issues –

Following code sample illustrates how you can obtain annotations from a JSON file and export them to a PDF document:

// Create instance of annotator.
AnnotationConfig cfg = CommonUtilities.GetConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
// Get file stream
Stream manifestResourceStream = new FileStream(CommonUtilities.MapSourceFilePath(filePath), FileMode.Open, FileAccess.ReadWrite);
List<AnnotationInfo> annotations = new List<AnnotationInfo>();
Stream stream = annotator.ExportAnnotationsToDocument(manifestResourceStream,annotations, DocumentType.Pdf);
// Save result stream to file.
using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.pdf"), FileMode.Create))
byte[] buffer = new byte[stream.Length];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(buffer, 0, buffer.Length);
fileStream.Write(buffer, 0, buffer.Length);

YouTube video tutorials of the .NET API –

Top comments (0)