Skip to content

Commit 9b312bc

Browse files
committed
998144: Authorization Header Support for Import Word and Export Word/PDF documentation
1 parent 4b514d2 commit 9b312bc

File tree

8 files changed

+297
-0
lines changed

8 files changed

+297
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public class HomeController : Controller
2+
{
3+
4+
public ActionResult Index()
5+
{
6+
ViewBag.RTEValue = "<h2 style=\"text-align: center;\">Invitation to Microsoft Webinar Meet-Up</h2><p> Dear Guest, </p><p> We're thrilled to extend a special invitation to you for an exclusive Microsoft webinar meet-up, where we'll explore the latest innovations and insights driving the future of technology. As a valued member of our community, we believe this event will offer invaluable knowledge and networking opportunities. </p><h2>Event Details:</h2><table class=\"e-rte-table\" style=\"width: 100%; height: 125px;\"> <tbody> <tr style=\"height: 20%;\"> <th class=\"\">Time:</th> <td>10:00 AM - 12:00 PM</td> </tr> <tr style=\"height: 20%;\"> <th>Duration:</th> <td>2 hours</td> </tr> <tr style=\"height: 20%;\"> <th>Platform:</th> <td>Microsoft Teams</td> </tr> </tbody></table><p><br></p><h2>Agenda:</h2><ul> <li>Introduction to Cutting-Edge Microsoft Technologies</li> <li>Deep Dive into AI in Business: Leveraging Microsoft Azure Solutions</li> <li>Live Q&amp;A Session with Industry Experts</li> <li>Networking Opportunities with Peers and Professionals</li> </ul><h2>Why Attend?</h2><ul> <li>Gain insights into the latest trends and advancements in technology.</li> <li>Interact with industry experts and expand your professional network.</li> <li>Get your questions answered in real-time during the live Q&amp;A session.</li> <li>Access exclusive resources and offers available only to webinar attendees.</li> </ul><p> Feel free to invite your colleagues and peers who might benefit from this enriching experience. Simply forward this email to them or share the event details. </p><p> We're looking forward to your participation and to exploring the exciting world of Microsoft technology together. Should you have any questions or require further information, please don't hesitate to contact us at <a href=\"mailto:webinar@company.com\">webinar@company.com</a>.</p><p> <br></p><p>Warm regards,</p><p>John Doe<br>Event Coordinator<br>ABC Company</p>";
7+
ViewBag.items = new[] { "Undo", "Redo", "|", "ExportWord", "ExportPdf", "|", "Bold", "Italic", "Underline", "StrikeThrough", "|",
8+
"FontName", "FontSize", "FontColor", "BackgroundColor", "|",
9+
"Formats", "Alignments", "Blockquote", "|", "NumberFormatList",
10+
"BulletFormatList", "|", "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "SourceCode"};
11+
ViewBag.InsertImageSettings = new Syncfusion.EJ2.RichTextEditor.RichTextEditorImageSettings
12+
{
13+
SaveUrl = hostUrl + "api/RichTextEditor/SaveFile",
14+
RemoveUrl = hostUrl + "api/RichTextEditor/DeleteFile",
15+
Path = hostUrl + "RichTextEditor/"
16+
};
17+
ViewBag.ExportWord = new Syncfusion.EJ2.RichTextEditor.RichTextEditorExportWord
18+
{
19+
ServiceUrl = hostUrl + "api/RichTextEditor/ExportToDocx",
20+
FileName = "RichTextEditor.docx",
21+
Stylesheet = ".e-rte-content{ font-size: 1em; font-weight: 400; margin: 0; }"
22+
};
23+
24+
ViewBag.ExportPdf = new Syncfusion.EJ2.RichTextEditor.RichTextEditorExportPdf
25+
{
26+
ServiceUrl = hostUrl + "api/RichTextEditor/ExportToPdf",
27+
FileName = "RichTextEditor.pdf",
28+
Stylesheet = ".e-rte-content{ font-size: 1em; font-weight: 400; margin: 0; }"
29+
};
30+
return View();
31+
}
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@Html.EJS().RichTextEditor("exportEditor").ToolbarSettings(e =>
2+
e.Items((object)ViewBag.items)).ExportWord(ViewBag.ExportWord).ExportPdf(ViewBag.ExportPdf).documentExporting("onDocumentExporting").Value((string)ViewBag.RTEValue).EnableXhtml(true).InsertImageSettings(ViewBag.InsertImageSettings).Render()
3+
4+
<script>
5+
function onDocumentExporting(args) {
6+
var accessToken = "Authorization_token";
7+
// Specify export type (e.g., 'Pdf' or 'Word')
8+
args.exportType = 'Pdf';
9+
// Add authentication header
10+
args.currentRequest = [{ Authorization: accessToken }];
11+
// Add custom form data
12+
args.customFormData = [{ userId: '1234' }, { exportMode: 'secure' }];
13+
}
14+
</script>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@{
2+
string rteValue = "<h2 style=\"text-align: center;\">Invitation to Microsoft Webinar Meet-Up</h2><p> Dear Guest, </p><p> We're thrilled to extend a special invitation to you for an exclusive Microsoft webinar meet-up, where we'll explore the latest innovations and insights driving the future of technology. As a valued member of our community, we believe this event will offer invaluable knowledge and networking opportunities. </p><h2>Event Details:</h2><table class=\"e-rte-table\" style=\"width: 100%; height: 125px;\"> <tbody> <tr style=\"height: 20%;\"> <th class=\"\">Time:</th> <td>10:00 AM - 12:00 PM</td> </tr> <tr style=\"height: 20%;\"> <th>Duration:</th> <td>2 hours</td> </tr> <tr style=\"height: 20%;\"> <th>Platform:</th> <td>Microsoft Teams</td> </tr> </tbody></table><p><br></p><h2>Agenda:</h2><ul> <li>Introduction to Cutting-Edge Microsoft Technologies</li> <li>Deep Dive into AI in Business: Leveraging Microsoft Azure Solutions</li> <li>Live Q&amp;A Session with Industry Experts</li> <li>Networking Opportunities with Peers and Professionals</li> </ul><h2>Why Attend?</h2><ul> <li>Gain insights into the latest trends and advancements in technology.</li> <li>Interact with industry experts and expand your professional network.</li> <li>Get your questions answered in real-time during the live Q&amp;A session.</li> <li>Access exclusive resources and offers available only to webinar attendees.</li> </ul><p> Feel free to invite your colleagues and peers who might benefit from this enriching experience. Simply forward this email to them or share the event details. </p><p> We're looking forward to your participation and to exploring the exciting world of Microsoft technology together. Should you have any questions or require further information, please don't hesitate to contact us at <a href=\"mailto:webinar@company.com\">webinar@company.com</a>.</p><p> <br></p><p>Warm regards,</p><p>John Doe<br>Event Coordinator<br>ABC Company</p>";
3+
object[] tools = new object[] {"Undo", "Redo", "|", "ExportWord", "ExportPdf", "|", "Bold", "Italic", "Underline", "StrikeThrough", "|",
4+
"FontName", "FontSize", "FontColor", "BackgroundColor", "|",
5+
"Formats", "Alignments", "Blockquote", "|", "NumberFormatList",
6+
"BulletFormatList", "|", "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "SourceCode" };
7+
string hostUrl = "https://services.syncfusion.com/aspnet/production/";
8+
RichTextEditorExportWord ExportWord = new RichTextEditorExportWord
9+
{
10+
ServiceUrl = hostUrl + "api/RichTextEditor/ExportToDocx",
11+
FileName = "RichTextEditor.docx",
12+
Stylesheet = ".e-rte-content{ font-size: 1em; font-weight: 400; margin: 0; }"
13+
};
14+
15+
RichTextEditorExportPdf ExportPdf = new RichTextEditorExportPdf
16+
{
17+
ServiceUrl = hostUrl + "api/RichTextEditor/ExportToPdf",
18+
FileName = "RichTextEditor.pdf",
19+
Stylesheet = ".e-rte-content{ font-size: 1em; font-weight: 400; margin: 0; }"
20+
};
21+
RichTextEditorImageSettings InsertImageSettings = new RichTextEditorImageSettings
22+
{
23+
SaveUrl = hostUrl + "api/RichTextEditor/SaveFile",
24+
RemoveUrl = hostUrl + "api/RichTextEditor/DeleteFile",
25+
Path = hostUrl + "RichTextEditor/"
26+
};
27+
}
28+
29+
<ejs-richtexteditor id="exportRTE" value="@rteValue" enableXhtml="true" documentExporting="onDocumentExporting">
30+
<e-richtexteditor-toolbarsettings items="@tools"></e-richtexteditor-toolbarsettings>
31+
<e-richtexteditor-insertimagesettings saveUrl="@InsertImageSettings.SaveUrl" removeUrl="@InsertImageSettings.RemoveUrl"
32+
path="@InsertImageSettings.Path"></e-richtexteditor-insertimagesettings>
33+
<e-richtexteditor-exportword serviceUrl="@ExportWord.ServiceUrl"
34+
fileName="@ExportWord.FileName" stylesheet="@ExportWord.Stylesheet">
35+
</e-richtexteditor-exportword>
36+
<e-richtexteditor-exportpdf serviceUrl="@ExportPdf.ServiceUrl"
37+
fileName="@ExportPdf.FileName" stylesheet="@ExportPdf.Stylesheet">
38+
</e-richtexteditor-exportpdf>
39+
</ejs-richtexteditor>
40+
41+
<script>
42+
function onDocumentExporting(args) {
43+
var accessToken = "Authorization_token";
44+
// Specify export type (e.g., 'Pdf' or 'Word')
45+
args.exportType = 'Pdf';
46+
// Add authentication header
47+
args.currentRequest = [{ Authorization: accessToken }];
48+
// Add custom form data
49+
args.customFormData = [{ userId: '1234' }, { exportMode: 'secure' }];
50+
}
51+
</script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class HomeController : Controller
2+
{
3+
4+
public ActionResult Index()
5+
{
6+
ViewBag.RTEValue = "<h2 style=\"text-align: center;\">Invitation to Microsoft Webinar Meet-Up</h2><p> Dear Guest, </p><p> We're thrilled to extend a special invitation to you for an exclusive Microsoft webinar meet-up, where we'll explore the latest innovations and insights driving the future of technology. As a valued member of our community, we believe this event will offer invaluable knowledge and networking opportunities. </p><h2>Event Details:</h2><table class=\"e-rte-table\" style=\"width: 100%; height: 125px;\"> <tbody> <tr style=\"height: 20%;\"> <th class=\"\">Time:</th> <td>10:00 AM - 12:00 PM</td> </tr> <tr style=\"height: 20%;\"> <th>Duration:</th> <td>2 hours</td> </tr> <tr style=\"height: 20%;\"> <th>Platform:</th> <td>Microsoft Teams</td> </tr> </tbody></table><p><br></p><h2>Agenda:</h2><ul> <li>Introduction to Cutting-Edge Microsoft Technologies</li> <li>Deep Dive into AI in Business: Leveraging Microsoft Azure Solutions</li> <li>Live Q&amp;A Session with Industry Experts</li> <li>Networking Opportunities with Peers and Professionals</li> </ul><h2>Why Attend?</h2><ul> <li>Gain insights into the latest trends and advancements in technology.</li> <li>Interact with industry experts and expand your professional network.</li> <li>Get your questions answered in real-time during the live Q&amp;A session.</li> <li>Access exclusive resources and offers available only to webinar attendees.</li> </ul><p> Feel free to invite your colleagues and peers who might benefit from this enriching experience. Simply forward this email to them or share the event details. </p><p> We're looking forward to your participation and to exploring the exciting world of Microsoft technology together. Should you have any questions or require further information, please don't hesitate to contact us at <a href=\"mailto:webinar@company.com\">webinar@company.com</a>.</p><p> <br></p><p>Warm regards,</p><p>John Doe<br>Event Coordinator<br>ABC Company</p>";
7+
ViewBag.Tools = new object[] {"Undo", "Redo", "|", "ImportWord", "|",
8+
"Bold", "Italic", "Underline", "StrikeThrough", "|",
9+
"FontName", "FontSize", "FontColor", "BackgroundColor", "|",
10+
"Formats", "Alignments", "Blockquote", "|", "NumberFormatList", "BulletFormatList",
11+
"|", "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "SourceCode"};
12+
string hostUrl = "https://services.syncfusion.com/aspnet/production/";
13+
ViewBag.InsertImageSettings = new Syncfusion.EJ2.RichTextEditor.RichTextEditorImageSettings
14+
{
15+
SaveUrl = hostUrl + "api/RichTextEditor/SaveFile",
16+
RemoveUrl = hostUrl + "api/RichTextEditor/DeleteFile",
17+
Path = hostUrl + "RichTextEditor/"
18+
};
19+
ViewBag.ImportWord = new Syncfusion.EJ2.RichTextEditor.RichTextEditorImportWord
20+
{
21+
ServiceUrl = hostUrl + "api/RichTextEditor/ImportFromWord",
22+
};
23+
return View();
24+
}
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@Html.EJS().RichTextEditor("importEditor").ToolbarSettings(e =>
2+
e.Items((object)ViewBag.Tools)).ImportWord(ViewBag.ImportWord).wordImporting("onWordImport").Value((string)ViewBag.RTEValue).EnableXhtml(true).InsertImageSettings(ViewBag.InsertImageSettings).Render()
3+
<script>
4+
function onWordImport(args) {
5+
var accessToken = "Authorization_token";
6+
// adding authorization header
7+
args.currentRequest.setRequestHeader('Authorization', accessToken)
8+
// adding custom form Data
9+
args.customFormData = [{'userId': '1234'}];
10+
}
11+
</script>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@{
2+
string rteValue = "<h2 style=\"text-align: center;\">Invitation to Microsoft Webinar Meet-Up</h2><p> Dear Guest, </p><p> We're thrilled to extend a special invitation to you for an exclusive Microsoft webinar meet-up, where we'll explore the latest innovations and insights driving the future of technology. As a valued member of our community, we believe this event will offer invaluable knowledge and networking opportunities. </p><h2>Event Details:</h2><table class=\"e-rte-table\" style=\"width: 100%; height: 125px;\"> <tbody> <tr style=\"height: 20%;\"> <th class=\"\">Time:</th> <td>10:00 AM - 12:00 PM</td> </tr> <tr style=\"height: 20%;\"> <th>Duration:</th> <td>2 hours</td> </tr> <tr style=\"height: 20%;\"> <th>Platform:</th> <td>Microsoft Teams</td> </tr> </tbody></table><p><br></p><h2>Agenda:</h2><ul> <li>Introduction to Cutting-Edge Microsoft Technologies</li> <li>Deep Dive into AI in Business: Leveraging Microsoft Azure Solutions</li> <li>Live Q&amp;A Session with Industry Experts</li> <li>Networking Opportunities with Peers and Professionals</li> </ul><h2>Why Attend?</h2><ul> <li>Gain insights into the latest trends and advancements in technology.</li> <li>Interact with industry experts and expand your professional network.</li> <li>Get your questions answered in real-time during the live Q&amp;A session.</li> <li>Access exclusive resources and offers available only to webinar attendees.</li> </ul><p> Feel free to invite your colleagues and peers who might benefit from this enriching experience. Simply forward this email to them or share the event details. </p><p> We're looking forward to your participation and to exploring the exciting world of Microsoft technology together. Should you have any questions or require further information, please don't hesitate to contact us at <a href=\"mailto:webinar@company.com\">webinar@company.com</a>.</p><p> <br></p><p>Warm regards,</p><p>John Doe<br>Event Coordinator<br>ABC Company</p>";
3+
object[] tools = new object[] {"Undo", "Redo", "|", "ImportWord", "|",
4+
"Bold", "Italic", "Underline", "StrikeThrough", "|",
5+
"FontName", "FontSize", "FontColor", "BackgroundColor", "|",
6+
"Formats", "Alignments", "Blockquote", "|", "NumberFormatList", "BulletFormatList",
7+
"|", "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "SourceCode" };
8+
string hostUrl = "https://services.syncfusion.com/aspnet/production/";
9+
10+
RichTextEditorImageSettings InsertImageSettings = new RichTextEditorImageSettings
11+
{
12+
SaveUrl = hostUrl + "api/RichTextEditor/SaveFile",
13+
RemoveUrl = hostUrl + "api/RichTextEditor/DeleteFile",
14+
Path = hostUrl + "RichTextEditor/"
15+
};
16+
RichTextEditorImportWord ImportWord = new RichTextEditorImportWord
17+
{
18+
ServiceUrl = hostUrl + "api/RichTextEditor/ImportFromWord",
19+
};
20+
}
21+
22+
<ejs-richtexteditor id="importRTE" value="@rteValue" wordImporting="onWordImport">
23+
<e-richtexteditor-toolbarsettings items="@tools"></e-richtexteditor-toolbarsettings>
24+
<e-richtexteditor-insertimagesettings saveUrl="@InsertImageSettings.SaveUrl"
25+
removeUrl="@InsertImageSettings.RemoveUrl"
26+
path="@InsertImageSettings.Path"></e-richtexteditor-insertimagesettings>
27+
<e-richtexteditor-importword serviceUrl="@ImportWord.ServiceUrl">
28+
<e-richtexteditor-wordImporting serviceUrl="@ImportWord.ServiceUrl">
29+
</e-richtexteditor-importword>
30+
</ejs-richtexteditor>
31+
32+
<script>
33+
function onWordImport(args) {
34+
var accessToken = "Authorization_token";
35+
// adding authorization header
36+
args.currentRequest.setRequestHeader('Authorization', accessToken)
37+
// adding custom form Data
38+
args.customFormData = [{'userId': '1234'}];
39+
}
40+
</script>

ej2-asp-core-mvc/rich-text-editor/EJ2_ASP.MVC/import-and-export.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,37 @@ The following example illustrates how to set up the `ImportWord` in the Rich Tex
4141
{% endtabs %}
4242
{% endif %}
4343

44+
## Secure importing with authentication
45+
46+
The Rich Text Editor provides functionality to import Word documents with authentication for secure importing.
47+
48+
The [wordImporting](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorWordImporting.html) event provides [UploadingEventArgs](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.inputs.uploader.html) for secure Word file import. Use `currentRequest` to add authentication headers and `customFormData` to include extra parameters in the POST body along with the uploaded file. On the server, read headers and form data from the request to validate and process the import securely.
49+
50+
The following example demonstrates how to configure `wordImporting` for secure importing:
51+
52+
{% if page.publishingplatform == "aspnet-core" %}
53+
54+
{% tabs %}
55+
{% highlight cshtml tabtitle="CSHTML" %}
56+
{% include code-snippet/rich-text-editor/secureimport/tagHelper %}
57+
{% endhighlight %}
58+
{% highlight c# tabtitle="Controller.cs" %}
59+
{% include code-snippet/rich-text-editor/secureimport/controller.cs %}
60+
{% endhighlight %}
61+
{% endtabs %}
62+
63+
{% elsif page.publishingplatform == "aspnet-mvc" %}
64+
65+
{% tabs %}
66+
{% highlight razor tabtitle="CSHTML" %}
67+
{% include code-snippet/rich-text-editor/secureimport/razor %}
68+
{% endhighlight %}
69+
{% highlight c# tabtitle="Controller.cs" %}
70+
{% include code-snippet/rich-text-editor/secureimport/controller.cs %}
71+
{% endhighlight %}
72+
{% endtabs %}
73+
{% endif %}
74+
4475
## Exporting Content to PDF and Microsoft Word
4576

4677
The Rich Text Editor's export functionality allows users to convert their edited content into PDF or Word documents with a single click, preserving all text styles, images, tables, and other formatting elements.
@@ -70,4 +101,35 @@ The following example demonstrates how to configure the `ExportWord` and `Export
70101
{% include code-snippet/rich-text-editor/export/controller.cs %}
71102
{% endhighlight %}
72103
{% endtabs %}
104+
{% endif %}
105+
106+
## Secure exporting with authentication
107+
108+
The Rich Text Editor provides functionality to export Word or PDF documents with authentication for secure exporting.
109+
110+
The [documentExporting](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorDocumentExporting.html) event provides `ExportingEventArgs` for secure export of Word or PDF files. Use `exportType` to identify the format, `currentRequest` to add authentication headers, and `customFormData` to send extra parameters in the POST body. On the server, read headers and custom data to validate and process the export securely.
111+
112+
The following example demonstrates how to configure `documentExporting` for secure exporting:
113+
114+
{% if page.publishingplatform == "aspnet-core" %}
115+
116+
{% tabs %}
117+
{% highlight cshtml tabtitle="CSHTML" %}
118+
{% include code-snippet/rich-text-editor/secureexport/tagHelper %}
119+
{% endhighlight %}
120+
{% highlight c# tabtitle="Controller.cs" %}
121+
{% include code-snippet/rich-text-editor/secureexport/controller.cs %}
122+
{% endhighlight %}
123+
{% endtabs %}
124+
125+
{% elsif page.publishingplatform == "aspnet-mvc" %}
126+
127+
{% tabs %}
128+
{% highlight razor tabtitle="CSHTML" %}
129+
{% include code-snippet/rich-text-editor/secureexport/razor %}
130+
{% endhighlight %}
131+
{% highlight c# tabtitle="Controller.cs" %}
132+
{% include code-snippet/rich-text-editor/secureexport/controller.cs %}
133+
{% endhighlight %}
134+
{% endtabs %}
73135
{% endif %}

0 commit comments

Comments
 (0)