Open document from absolute path and annotate it using .NET

Hello,

I’m migrating annotation to 3.1.0 from 2.x(dont remember exact version right now). But i found an issue that cause error. If i give absolute document path(ex: C:\test\abc.docx) annotation gives an error on “annotator.GetDocumentInfo(request.Path)” method. Error says "Cannot create “C:\test\abc.docx”
because a file or directory with the same name already exists."

But if i move document to App_Data folder and give filename(abc.docx) instead of absolute path, it works.

Also i’m implemented groupdocs viewer 3.6.0 in our project. I checked it too, i’m using same pattern in viewer to “_imageHandler.GetDocumentInfo(request.Path)” method. But when i’m using it, in that method absolute path changes and it replaces special characters then write it to temp folder.

I assume that if “annotator.GetDocumentInfo(request.Path)” method also replaces special characters as imagehandler or htmlhandler. This wont be a problem.

Also i’m checked your sample too, usage of GetDocumentInfo method is same but in your sample you’re using filename instead of absolute path.

Could you check this issue?

Hi,


Thank you for giving a try to next generation GroupDocs.Annotation for .NET API.

Please click here to download the latest and open source MVC Front-End application with new generation GoupDocs.Annotation for .NET API.

If you use this “annotator.GetDocumentInfo(“C:/Test/abc.docx”)” then the absolute document path will be concatenate with the AnnotationConfig “StoragePath” and exception will be generated.

To properly use the absolute path like “C:/Test/” instead of “~/App_Data/”, you only need to update the “RegisterTypes” method and assign a desired absolute path to this local variable “repositoryFolder” in the “/App_Start/UnityConfig.cs”, later this variable will be assigned to AnnotationConfig “StoragePath” property.

string repositoryFolder = “C:/Test/”; AppDomain.CurrentDomain.GetData(“DataDirectory”) + “/”;

Please download latest source code from our GitHub repository and try the solution by yourself.

If you will need any help or you will have any other questions please feel free to ask.

Warm Regards,

Hello,

I understand your point.

But i dont understand this;

If i gave absolute path to Groupdocs.Viewer, its works without any problem. But it doesnt work on Groupdocs.Annotation. I understand that they are different but in the end their base and first purpose is viewing documents.

When i gave absolute path to Groupdocs.Viewer it replaces special characters to _, after that viewer concatenate storagePath and changed absolute path. And its works like a charm. Why they are not work same way.

I’m insisting it because, in our project source path can be different for documents. And we dont want to move documents every time.

Isn’t it possible Groupdocs.Viewer and Groupdocs.Annotation(Viewer part) works same?

Hi,


Front-End for GroupDocs.Viewer and GroupDocs.Annotation both are open source and both have different approaches to render documents as per their application architecture and requirements.

GroupDocs.Viewer fron-end provide the rich interface to view documents and GroupDocs.Annotation front-end provide the rich interface to annotate the document and view document according to annotation features and rendering regions from data storage supported files that also generate while annotating a document.

If you want to manage the input and output file approach same for both application then you can customize it according to your need.

If you will need any help or you will have any other questions please feel free to ask.

Warm Regards,

Hello,

I want to manage input and output. I checked your sample project. I found DocumentInfoRepository.cs and FileRepository classes to manage input/output in your sample project. I implemented them in my project. Also added them to unity config like below;

var annotator = new AnnotationImageHandler(
new AnnotationConfig { StoragePath = repositoryFolder, TempPath = tempPath },
new Data.Repositories.UserRepository(),
new Data.Repositories.AnnotationDocumentRepository(),
new Data.Repositories.AnnotationRepository(),
new Data.Repositories.AnnotationReplyRepository(),
new Data.Repositories.AnnotationCollaboratorRepository(),
new Data.Repositories.FileRepository(repositoryFolder),
new Data.Repositories.DocumentInfoRepository(repositoryFolder));
By the way, i created a dll to manage annotation datas. We want to store them in sql/oracle db.

But in your sample FileRepository and DocumentInfoRepository class contains NotImplemented methods. And a couple method doesn’t contain in interfaces.
My question is how should i implemented those methods. Because some of them are called from AnnotationImageHandler.GetDocumentInfo() method. When i debug FileRepository and DocumentInfoRepository i get following results;

AnnotationImageHandler.GetDocumentInfo() method’s first call is FileRepository.GetFileDescription(string guid) method. This method was notimplemented(I’m talking throw new NotImplementedException() kind not implemented). I create new FileDescription instance and everything is fine. BTW guid variable was my absolute path(as i wanted)

Then it calls DocumentInfoMethod.GetFileData(FileDescription fileDescription) method. This was notimplemented too. This method returns FileData object, and i create a new instance of FileData class and return it as default. But i guess this object must be filled and this object has contains properties like pages, pageCount, maxHeight, maxWidth. For filling them i have to process document. Is this mandatory? Or could you give me a sample of usage this method, if you have. Also do i need to do anything beside filling FileData instance?

Then it calls FileRepository.GetFile(string guid) method. In this method guid variable is “Temp//abc.pdf”. It should be in my repositoryFolder, i guess i have to create it by myself? Or is there a helper class/method to create it? Or where should i create it(i mean which class-method)?

Because of abc.docx not exist i cant go further.

One last think do you have any fully implemented sample about this subject?

Kind regards,

@fkucuk,

Please download and run our latest UI projects and let us know if you face any issue in them.