@@ -420,4 +420,70 @@ public WordDocument GetDocument(string htmlText)
420420{% endhighlight %}
421421{% endtabs %}
422422
423- N> [ View Sample in GitHub] ( https://github.com/SyncfusionExamples/blazor-rich-text-editor-export-to-html ) .
423+ N> [ View Sample in GitHub] ( https://github.com/SyncfusionExamples/blazor-rich-text-editor-export-to-html ) .
424+
425+ ## Export Document/PDF with Authentication
426+
427+ You can add additional data while exporting a document from the Rich Text Editor. When exporting, the OnExport event is triggered, allowing you to:
428+
429+ - Add custom headers to the request using the ` CurrentRequest ` property (for example, passing an authentication token).
430+
431+ - Send custom form data to the server using the ` CustomFormData ` property.
432+
433+ On the server side, you can fetch the authentication token from the request headers and retrieve the custom form data.
434+
435+ The following example demonstrates how to achieve this:
436+
437+ {% tabs %}
438+ {% highlight razor %}
439+
440+ @using Syncfusion.Blazor.RichTextEditor
441+ <SfRichTextEditor >
442+ <RichTextEditorEvents OnExport="@Export" />
443+ <RichTextEditorToolbarSettings Items="@Items" />
444+ <RichTextEditorExportPdf ServiceUrl="@exportPdfServiceUrl" />
445+ <RichTextEditorExportWord ServiceUrl="@exportWordServiceUrl" />
446+ Rich Text Editor
447+ </SfRichTextEditor >
448+ @code {
449+ private string exportWordServiceUrl = "https://blazor.syncfusion.com/services/production/api/RichTextEditor/ExportToDocx ";
450+ private string exportPdfServiceUrl = "https://blazor.syncfusion.com/services/production/api/RichTextEditor/ExportToPdf ";
451+ private List<ToolbarItemModel > Items = new List<ToolbarItemModel >()
452+ {
453+ new ToolbarItemModel() { Command = ToolbarCommand.ExportPdf },
454+ new ToolbarItemModel() { Command = ToolbarCommand.ExportWord },
455+ };
456+ private void Export(ExportingEventArgs args)
457+ {
458+ args.CurrentRequest = new Dictionary<string, string>
459+ {
460+ { "Authorization", "Bearer token" }
461+ };
462+ args.CustomFormData = new Dictionary<string, string>
463+ {
464+ { "userId", "12345" }
465+ };
466+ }
467+ }
468+
469+ {% endhighlight %}
470+ {% endtabs %}
471+
472+ {% tabs %}
473+ {% highlight cshtml tabtitle="~ /ExportService.cs" %}
474+ public class ExportParam
475+ {
476+ public string? html { get; set; }
477+ public object? formData { get; set; }
478+ }
479+ [ AcceptVerbs("Post")]
480+ [ EnableCors("AllowAllOrigins")]
481+ [ Route("ExportToPdf")]
482+ public async Task<ActionResult > ExportToPdf([ FromBody] ExportParam args)
483+ {
484+ var authorization = Request.Headers[ "Authorization"] ;
485+ Console.WriteLine(args.formData);
486+ Console.WriteLine(args.html);
487+ }
488+ {% endhighlight %}
489+ {% endtabs %}
0 commit comments