Free Support Forum -

Document showing previous drawing


I load document for annotation and added some drawing to it and then i am taking screen shot of it.
But when i load same document second time previous changes remains on it.
what i want is each time i load document it should be new means without showing previous drawing.
Is it possible and how ?


Hello Hiren,

If I understand you correctly, you want to clear all existing annotations (if they are present) for specified document right before displaying this document on the web-page using GroupDocs.Annotation for .NET.

If I’m right then the answer on your question is - yes, this is possible. You need to remove all annotations for the specified document. Here is a source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using AnnotationDemo.Models;
using Groupdocs.Annotation;
using Groupdocs.Api.Contract;
using Groupdocs.Data;
using Groupdocs.Web.Annotation;
using StructureMap;

//Filename is a String variable which contains filename of the target document
Int64 sessionId = FileSessionMapper.Instance[Filename];
if (sessionId == 0)
//this document has never opened using GroupDocs.Annotation

Groupdocs.Core.IAnnotationService annotationSvc = StructureMap.ObjectFactory.GetInstance<Groupdocs.Core.IAnnotationService>();
Groupdocs.Data.Annotation[] all_annotations = annotationSvc.GetSessionAnnotations(sessionId);
Groupdocs.Annotation.IAnnotator annotator = ObjectFactory.GetInstance();
foreach (Annotation one_annotation in all_annotations)


You may put this code to the “Page_Load” method which fires right before the page rendering or wherever you want.

This code obtains an array of all present annotations for the specified document “Filename” and then removes them through iterations.

If you will have more questions please feel free to contact us.