DEV Community 👩‍💻👨‍💻

GroupDocs
GroupDocs

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 – http://bit.ly/2T5VBeQ

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);
fileStream.Close();
}

YouTube video tutorials of the .NET API – http://bit.ly/2Sod3vn

Top comments (0)

We are hiring! Do you want to be our Senior Platform Engineer? Are you capable of chipping in across sysadmin, ops, and site reliability work, while supporting the open source stack that runs DEV and other communities?

This role might just be for you!

Apply now