Skip to content

Commit c6a8187

Browse files
Added sample for Show track changes mark up
1 parent ec08ebd commit c6a8187

File tree

77 files changed

+74427
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+74427
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34205.153
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Show-track-changes-mark-up", "Show-track-changes-mark-up\Show-track-changes-mark-up.csproj", "{FBB997E8-F6F7-4C66-AC36-F6523FAB9B39}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FBB997E8-F6F7-4C66-AC36-F6523FAB9B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FBB997E8-F6F7-4C66-AC36-F6523FAB9B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FBB997E8-F6F7-4C66-AC36-F6523FAB9B39}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FBB997E8-F6F7-4C66-AC36-F6523FAB9B39}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {38ECEAB5-1460-4B24-BE9A-307856A52CAA}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Show_track_changes_mark_up.Models;
3+
using System.Diagnostics;
4+
using Syncfusion.DocIO;
5+
using Syncfusion.DocIO.DLS;
6+
using Syncfusion.DocIORenderer;
7+
using Syncfusion.Pdf;
8+
using System.Reflection.Metadata;
9+
10+
namespace Show_track_changes_mark_up.Controllers
11+
{
12+
public class HomeController : Controller
13+
{
14+
private readonly ILogger<HomeController> _logger;
15+
16+
public HomeController(ILogger<HomeController> logger)
17+
{
18+
_logger = logger;
19+
}
20+
21+
public IActionResult Index()
22+
{
23+
return View();
24+
}
25+
public ActionResult ConvertWordtoPDF(string TrackChangesOptions, string button)
26+
{
27+
//Open the file as Stream.
28+
using (FileStream docStream = new FileStream(Path.GetFullPath("Data/Template.docx"), FileMode.Open, FileAccess.Read))
29+
{
30+
//Loads file stream into Word document.
31+
using (WordDocument wordDocument = new WordDocument(docStream, FormatType.Automatic))
32+
{
33+
#region Track changes option
34+
//Sets revision types to preserve simple markup track changes in Word to PDF conversion.
35+
if (TrackChangesOptions == "0")
36+
{
37+
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions | RevisionType.MoveFrom | RevisionType.MoveTo | RevisionType.StyleDefinitionChange;
38+
wordDocument.RevisionOptions.ShowInBalloons = RevisionType.None;
39+
}
40+
//Sets revision types to preserve all markup track changes in Word to PDF conversion.
41+
else if (TrackChangesOptions == "1")
42+
{
43+
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions | RevisionType.MoveFrom | RevisionType.MoveTo | RevisionType.StyleDefinitionChange;
44+
}
45+
//Sets none revision type to preserve no markup track changes in Word to PDF conversion.
46+
else if (TrackChangesOptions == "2")
47+
{
48+
wordDocument.RevisionOptions.ShowMarkup = RevisionType.None;
49+
}
50+
#endregion
51+
//Instantiation of DocIORenderer for Word to PDF conversion.
52+
using (DocIORenderer render = new DocIORenderer())
53+
{
54+
//Converts Word document into PDF document.
55+
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);
56+
57+
//Saves the PDF document to MemoryStream.
58+
MemoryStream stream = new MemoryStream();
59+
pdfDocument.Save(stream);
60+
stream.Position = 0;
61+
62+
//Download PDF document in the browser.
63+
return File(stream, "application/pdf", "Sample.pdf");
64+
}
65+
}
66+
}
67+
}
68+
public IActionResult Privacy()
69+
{
70+
return View();
71+
}
72+
73+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
74+
public IActionResult Error()
75+
{
76+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
77+
}
78+
}
79+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Show_track_changes_mark_up.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
10+
{
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
14+
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:11109",
7+
"sslPort": 44341
8+
}
9+
},
10+
"profiles": {
11+
"Show_track_changes_mark_up": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7092;http://localhost:5033",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<RootNamespace>Show_track_changes_mark_up</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@{
2+
Html.BeginForm("ConvertWordtoPDF", "Home", FormMethod.Get);
3+
{
4+
<div class="Common">
5+
<div class="tablediv">
6+
<div class="rowdiv">
7+
This sample illustrates how to show track changes mark up in Word to PDF conversion using Essential DocIO.
8+
</div>
9+
&nbsp;
10+
<div class="rowdiv" style="border-width: 0.5px;border-style:solid; border-color: lightgray; padding: 1px 5px 7px 5px">
11+
<div class="rowdiv" style="margin-top: 8px">
12+
<input type="submit" value="Convert Word to PDF" name="button" style="width:200px;height:27px" />
13+
<br />
14+
</div>
15+
<div>
16+
Select Track changes option:
17+
<select id="TrackChangesOptions" name="TrackChangesOptions">
18+
<option value="0">Simple Markup</option>
19+
<option value="1">All Markup</option>
20+
<option value="2">No Markup</option>
21+
</select>
22+
23+
</div>
24+
</div>
25+
</div>
26+
<br />
27+
</div>
28+
}
29+
Html.EndForm();
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
ViewData["Title"] = "Privacy Policy";
3+
}
4+
<h1>@ViewData["Title"]</h1>
5+
6+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@model ErrorViewModel
2+
@{
3+
ViewData["Title"] = "Error";
4+
}
5+
6+
<h1 class="text-danger">Error.</h1>
7+
<h2 class="text-danger">An error occurred while processing your request.</h2>
8+
9+
@if (Model.ShowRequestId)
10+
{
11+
<p>
12+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
13+
</p>
14+
}
15+
16+
<h3>Development Mode</h3>
17+
<p>
18+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19+
</p>
20+
<p>
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
25+
</p>

0 commit comments

Comments
 (0)