- Home
- Forum
- Angular - EJ 2
- possibility to manually accept or decliend track change changes
possibility to manually accept or decliend track change changes
Hi,
I am using document editor (Version: 19.2.44) in my Angular Application.
I would like to know if it is possible to manually accept/decline changes tracked by track changes functionality.
Manually I mean: accept changes by from ts file.
Also If possible, How can I accept or decliend all changes manually from .ts file.
Regards,
|
documentEditor.revisions.acceptAll()
documentEditor.revisions.rejectAll() |
Hi Suriya,
Your suggestion helped me. Working fine.
I need small requirement with Accept, decliend, AcceptAll and declinedAll method. I would like to listen these event. I want to execute some funcion whenever user perform any of these action.
Regards,
Parth
Hi Suriya,
So I tried to explain my case:
- whenever user click on the AcceptAll, User could able to make further changes without track changes and also able to save docx into database
- whenever user click on the DeclinedAll, User should not able to make any further changes in editor and just save docx in database
- if single changes is declined than I wanted to store docx in different table
Hi Kurthis,
Thank you for providing inputs for the requirement.
to be honest, I didn't unserstand the how it's goona work.
I did added SaveDocument Method into my DocumentEditorCntroller.cs file. As I using docker contianer for .Net Core API, I compiled and it compiled sucessfully with your code.
Than I added trackchanges property into DocumentEdiotr like this:
<ejs-documenteditorcontainer #documentEditorDefault [enableLocalPaste]=false [enableToolbar]=true
id="documentEditorDefault" [locale]="locale" name="documentEditor"
(keydown)="onClipboardPast($event)" [toolbarItems]="toolbarItems" (trackChange)="trackChangesEvent($event)"
(contentChange)="onContentChange($event)" [enableTrackChanges]=trackChangesBool
(created)="onCreate()" (documentChange)="onDocumentChange()" [currentUser]="currentUser"
(drop)="onDragEditor($event)" (selectionChange)="onSelectionChange()">
</ejs-documenteditorcontainer>
Now whenever I accept or reject nothing is happening in case of listing accept/declined event.
Can you please provide me the example of your suggestion and what expected result it gives me after implementing this code?
Also is it possible to make this issue as an instance to solve it fast pace.
Regards,
Parth
Intuitive user interface to track changes in Syncfusion Word Processor
|
Note: Word Processor (Document Editor) component requires server-side interaction for the below-listed operations.
You can get the Web API project from this GitHub location. |
Accept or reject changes using Syncfusion DocIO Word library
|
//Reads the input Word document
//Kindly give your path with input document.
Stream inputStream = File.OpenRead(Path.GetFullPath(@"../../../../../../Data/InputWithTrackedChanges.docx"));
string authorName = "Steven Buchanan";
int acceptedChangesCount = AcceptChanges(inputStream, authorName);
Console.WriteLine("Accepted {0} changes made by {1}.", acceptedChangesCount, authorName);
static int AcceptChanges(Stream inputStream, string authorName)
{
int acceptedChangesCount = 0;
//Creates new Word document instance for Word processing
using (WordDocument document = new WordDocument())
{
//Opens the Word document containing tracked changes
document.Open(inputStream, FormatType.Docx);
inputStream.Dispose();
//Iterates all the revisions present in the Word document
for (int i = document.Revisions.Count - 1; i >= 0; i--)
{
//Validates the author of current revision to accepts/rejects it
if (document.Revisions[i].Author == authorName)
{
//Accepts the current revision
document.Revisions[i].Accept();
acceptedChangesCount++;
}
//Resets i to last item, since accepting one revision will impact all its related revisions and leads to change in Revsions
if (i > document.Revisions.Count - 1)
i = document.Revisions.Count;
}
//Saves the Word document as DOCX format
using (Stream docStream = File.Create(Path.GetFullPath(@"../../../OutputAfterAcceptingChanges.docx")))
{
document.Save(docStream, FormatType.Docx);
}
}
return acceptedChangesCount;
} |
Reject the changes
|
//Reads the input Word document
Stream inputStream = File.OpenRead(Path.GetFullPath(@"../../../../../../Data/InputWithTrackedChanges.docx"));
RevisionType revisionType = RevisionType.Insertions | RevisionType.Deletions;
int rejectedChangesCount = RejectChanges(inputStream, revisionType);
static int RejectChanges(Stream inputStream, RevisionType revisionType)
{
int rejectedChangesCount = 0;
//Creates new Word document instance for Word processing
using (WordDocument document = new WordDocument())
{
//Opens the Word document containing tracked changes
document.Open(inputStream, FormatType.Docx);
inputStream.Dispose();
//Iterates all the revisions present in the Word document
for (int i = document.Revisions.Count - 1; i >= 0; i--)
{
//Validates the revision type of current revision to accepts/rejects it
if ((document.Revisions[i].RevisionType & revisionType) != 0)
{
//Rejects the current revision
document.Revisions[i].Reject();
rejectedChangesCount++;
}
//Resets i to last item, since rejecting one revision will impact all its related revisions and lead to change in Revsions
if (i > document.Revisions.Count - 1)
i = document.Revisions.Count;
}
//Saves the Word document as DOCX format
using (Stream docStream = File.Create(Path.GetFullPath(@"../../../OutputAfterRejectingChanges.docx")))
{
document.Save(docStream, FormatType.Docx);
}
}
return rejectedChangesCount;
} |
- 8 Replies
- 3 Participants
-
PK Parthkumar Kakadiya
- Aug 3, 2021 01:45 PM UTC
- Aug 19, 2021 05:04 AM UTC