Skip to content

Commit a41974a

Browse files
Added the FormFields, ContentControl, TrackChanges and Fields documentation
1 parent e6f6c74 commit a41974a

File tree

12 files changed

+1915
-0
lines changed

12 files changed

+1915
-0
lines changed

java-file-formats-toc.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<li>
3737
<a href="/java-file-formats/word-library/working-with-bookmarks">Working with Bookmarks</a>
3838
</li>
39+
<li>
40+
<a href="/java-file-formats/word-library/working-with-fields">Working with Fields</a>
41+
</li>
3942
<li>
4043
<a href="/java-file-formats/word-library/working-with-shapes">Working with Shapes</a>
4144
</li>
@@ -55,6 +58,15 @@
5558
<li>
5659
<a href="/java-file-formats/word-library/working-with-comments">Working with Comments</a>
5760
</li>
61+
<li>
62+
<a href="/java-file-formats/word-library/working-with-form-fields">Working with Form Fields</a>
63+
</li>
64+
<li>
65+
<a href="/java-file-formats/word-library/working-with-content-controls">Working with Content Controls</a>
66+
</li>
67+
<li>
68+
<a href="/java-file-formats/word-library/accepting-or-rejecting-track-changes">Accepting or Rejecting Track Changes</a>
69+
</li>
5870
<li>
5971
<a href="/java-file-formats/word-library/conversion">Working with Document Conversion</a>
6072
<ul>
39.4 KB
Loading
35 KB
Loading
47.8 KB
Loading
39.1 KB
Loading
48.9 KB
Loading
69.2 KB
Loading
62.7 KB
Loading
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
title: Accepting or Rejecting Track Changes | DocIO | Syncfusion
3+
description: This section illustrates how to Accept or Reject the Track changes in the Word document using Syncfusion Word library (Essential DocIO)
4+
platform: java-file-formats
5+
control: Word Library
6+
documentation: UG
7+
---
8+
# Accepting or Rejecting Track Changes
9+
10+
It is used to keep track of the changes made to a Word document. It helps to maintain the record of author, name and time for every insertion, deletion, or modification in a document. This can be enabled by using the TrackChanges property of the Word document.
11+
12+
N>
13+
With this support, the changes made in the Word document by DocIO library cannot be tracked.
14+
15+
The following code example illustrates how to enable track changes of the document.
16+
17+
{% tabs %}
18+
19+
{% highlight JAVA %}
20+
//Creates a new Word document.
21+
WordDocument document = new WordDocument();
22+
//Adds new section to the document.
23+
IWSection section = document.addSection();
24+
//Adds new paragraph to the section.
25+
IWParagraph paragraph = section.addParagraph();
26+
//Appends text to the paragraph.
27+
IWTextRange text = paragraph.appendText("This sample illustrates how to track the changes made to the word document. ");
28+
//Sets font name and size for text.
29+
text.getCharacterFormat().setFontName("Times New Roman");
30+
text.getCharacterFormat().setFontSize((float)14);
31+
text=paragraph.appendText("This track changes is useful in shared environment.");
32+
text.getCharacterFormat().setFontSize((float)12);
33+
//Turns on the track changes option.
34+
document.setTrackChanges(true);
35+
//Saves and closes the document.
36+
document.save("Sample.docx", FormatType.Docx);
37+
document.close();
38+
{% endhighlight %}
39+
40+
{% endtabs %}
41+
42+
## Accept all changes
43+
44+
You can **accept all track changes in Word document** using `AcceptAll`method.
45+
46+
The following code example shows how to accept all the tracked changes.
47+
48+
{% tabs %}
49+
50+
{% highlight JAVA %}
51+
//Opens an existing Word document.
52+
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
53+
//Accepts all the tracked changes revisions.
54+
if(document.getHasChanges())
55+
document.getRevisions().acceptAll();
56+
//Saves and closes the document.
57+
document.save("Sample.docx", FormatType.Docx);
58+
document.close();
59+
{% endhighlight %}
60+
61+
{% endtabs %}
62+
63+
By executing the above code example, it generates output Word document as follows.
64+
65+
![Accepting all track changes in Word document](WorkingWithTrackChanges_images/AcceptAll.png)
66+
67+
## Reject all changes
68+
69+
You can **reject all track changes in Word document** using `RejectAll` method.
70+
71+
The following code example shows how to reject all the tracked changes.
72+
73+
{% tabs %}
74+
75+
{% highlight JAVA %}
76+
//Opens an existing Word document.
77+
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
78+
//Rejects all the tracked changes revisions.
79+
if(document.getHasChanges())
80+
document.getRevisions().rejectAll();
81+
//Saves and closes the document.
82+
document.save("Sample.docx", FormatType.Docx);
83+
document.close();
84+
{% endhighlight %}
85+
86+
{% endtabs %}
87+
88+
By executing the above code example, it generates output Word document as follows.
89+
90+
![Rejecting all track changes in Word document](WorkingWithTrackChanges_images/RejectAll.png)
91+
92+
## Accept all changes by a particular reviewer
93+
94+
You can **accept all changes made by the author** in the Word document using `Accept` method.
95+
96+
The following code example shows how to accept the tracked changes made by the author.
97+
98+
{% tabs %}
99+
100+
{% highlight JAVA %}
101+
//Opens an existing Word document.
102+
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
103+
//Iterates into all the revisions in Word document.
104+
for (int i = document.getRevisions().getCount() - 1; i >= 0; i--)
105+
{
106+
//Checks the author of current revision and accepts it.
107+
if(document.getRevisions().get(i).getAuthor().equals("Nancy Davolio"))
108+
document.getRevisions().get(i).accept();
109+
//Resets to last item when accept the moving related revisions.
110+
if (i > document.getRevisions().getCount() - 1)
111+
i = document.getRevisions().getCount();
112+
}
113+
//Saves and closes the document.
114+
document.save("Sample.docx", FormatType.Docx);
115+
document.close();
116+
{% endhighlight %}
117+
118+
{% endtabs %}
119+
120+
## Reject all changes by particular reviewer
121+
122+
You can **reject all changes made by the author** in the Word document using `Reject` method.
123+
124+
The following code example shows how to reject the tracked changes made by the author.
125+
126+
{% tabs %}
127+
128+
{% highlight JAVA %}
129+
//Opens an existing Word document.
130+
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
131+
//Iterates into all the revisions in Word document.
132+
for (int i = document.getRevisions().getCount() - 1; i >= 0; i--)
133+
{
134+
//Checks the author of current revision and rejects it.
135+
if(document.getRevisions().get(i).getAuthor().equals("Nancy Davolio"))
136+
document.getRevisions().get(i).reject();
137+
//Resets to last item when reject the moving related revisions.
138+
if (i > document.getRevisions().getCount() - 1)
139+
i = document.getRevisions().getCount();
140+
}
141+
//Saves and closes the document.
142+
document.save("Sample.docx", FormatType.Docx);
143+
document.close();
144+
{% endhighlight %}
145+
146+
{% endtabs %}
147+
148+
## Revision information
149+
150+
You can get the **revision information of track changes** in the Word document like author name, date, and type of revision.
151+
152+
The following code example shows how to get the details about the revision information of track changes.
153+
154+
{% tabs %}
155+
156+
{% highlight JAVA %}
157+
//Opens an existing Word document.
158+
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
159+
//Accesses the first revision in the word document.
160+
Revision revision = document.getRevisions().get(0);
161+
//Gets the name of the user who made the specified tracked change.
162+
String author = revision.getAuthor();
163+
// Gets the date and time that the tracked change was made.
164+
LocalDateTime dateTime = revision.getDate();
165+
// Gets the type of the track changes revision.
166+
RevisionType revisionType = revision.getRevisionType();
167+
//Closes the document.
168+
document.close();
169+
{% endhighlight %}
170+
171+
{% endtabs %}
172+
173+
Frequently Asked Questions
174+
175+
* How to check whether a Word document contains tracked changes or not?
176+
* How to accept or reject track changes of specific type in the Word document?
177+
* How to enable track changes for Word document?

0 commit comments

Comments
 (0)