GroupDocs.Annotation for .NET 17.7.0 Release Notes

Major Features

Below the list of  new features and fixed bugs in this regular monthly release of GroupDocs.Annotation for .NET. The most notable are:

  • Fixed SVG path parsing for specific cases
  • Implemented annotations import for Diagrams format (Area Redaction, Polyline, Text Field, Area Redaction)
  • Implemented setting opacity to annotations where it is possible
  • Exceptions handling improvements (added several more specific type of exceptions)

Full List of Issues Covering all Changes in this Release

KeySummaryIssue Type
ANNOTATIONNET-448Set opacity for Diagrams annotationsNew Feature
ANNOTATIONNET-447Set opacity for Pdf annotationsNew Feature
ANNOTATIONNET-446Set opacity for Words annotationsNew Feature
ANNOTATIONNET-445Set opacity for Slides annotationsNew Feature
ANNOTATIONNET-442Implement additional specific exceptionsImprovement
ANNOTATIONNET-441Import text field annotation from DiagramNew Feature
ANNOTATIONNET-440Import polyline annotation from DiagramNew Feature
ANNOTATIONNET-439Import Area Redaction annotation from diagramNew Feature
ANNOTATIONNET-438Import area annotation from diagramNew Feature
ANNOTATIONNET-430Implement import annotations for DiagramNew Feature
ANNOTATIONNET-421Bug with parsing specific SVG pathBug
ANNOTATIONNET-419Implement TextField annotation for DiagramsNew Feature

Public API and Backward Incompatible Changes

How to use Opacity

// 1. To AnnotationInfo object added new Opacity field that sets opacity of annotation (can be null or float number between 0 and 1)

	public double? Opacity { get; set; }


// 2. Text annotation.
AnnotationInfo textAnnotation = new AnnotationInfo
{
    Box = new Rectangle(68, 154, 102, 9),
    PageNumber = 0,
    SvgPath = "[{\"x\":68.7886,\"y\":687.5769},{\"x\":170.8186,\"y\":687.5769},{\"x\":68.7886,\"y\":678.5769},{\"x\":170.8186,\"y\":678.5769}]",
    Type = AnnotationType.Text,
    CreatorName = "Anonym A."
    CreatorName = "Anonym A.",
	Opacity = 0.1
};

Import annotations from Diagram documents

using System.IO;
using System.Linq;
using System.Reflection;
using GroupDocs.Annotation;
using GroupDocs.Annotation.Config;
using GroupDocs.Annotation.Domain;
using GroupDocs.Annotation.Handler;
namespace ImportAnnotationsDiagram
{
    class Program
    {
        static void Main(string[] args)
        {
            AnnotationConfig cfg = new AnnotationConfig();
            cfg.StoragePath = "StorageFolder";
            AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
            if (!Directory.Exists(cfg.StoragePath))
            {
                Directory.CreateDirectory(cfg.StoragePath);
            }
            new License().SetLicense(@"path_to_licence");
            Stream input = new FileStream("../../testImportArrow.vsdx", FileMode.Open,FileAccess.ReadWrite); 
 
            AnnotationInfo[] annotations = annotator.ImportAnnotations(input, DocumentType.Diagram);
            Stream clearDocument = new FileStream("../../testClear.vsd", FileMode.Open,FileAccess.ReadWrite); 
            Stream output = annotator.ExportAnnotationsToDocument(clearDocument, annotations.ToList(), DocumentType.Diagram);

            using (FileStream fileStream = new FileStream("../../testDiagramExported.vsdx", FileMode.Create))
            {
                byte[] buffer = new byte[output.Length];
                output.Seek(0L, SeekOrigin.Begin);
                output.Read(buffer, 0, buffer.Length);
                fileStream.Write(buffer, 0, buffer.Length);
                fileStream.Close();
            }
        }
    }
}