Search results

Server side export in Angular DocumentEditor component

05 Aug 2021 / 2 minutes to read

SFDT to DOCX export

Document editor supports server-side export of Syncfusion Document Text (.SFDT) to Doc, DOCX, RTF, Txt, WordML, Html formats using server-side helper Syncfusion.EJ2.DocumentEditor available in ASP.NET Core & ASP.NET MVC platform in the below NuGet’s.

Please refer the following code example.

Copied to clipboard
//API controller for the conversion.
public void ExportSFDT([FromBody]SaveParameter data)
Stream document = WordDocument.Save(data.content, FormatType.Docx);
FileStream file = new FileStream("sample.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);

public class SaveParameter
public string content { get; set; }

Please refer the client side example to serialize the sfdt and send to the server.

Copied to clipboard
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import {
DocumentEditorComponent, EditorService, SelectionService, SfdtExportService, TextExportService, WordExportService
} from '@syncfusion/ej2-angular-documenteditor';

selector: 'app-container',
template: `<div style="width:100%;height:330px"><button ejs-button (click)="saveAsSfdt()" >Export SFDT</button>
<ejs-documenteditor #document_editor  id="container" style="width:100%;height:100%;display:block" [isReadOnly]=false [enableEditor]=true [enableWordExport]=true [enableSfdtExport]=true> </ejs-documenteditor></div>`,
encapsulation: ViewEncapsulation.None,
providers: [EditorService, SelectionService, SfdtExportService,TextExportService]

export class AppComponent {
 public documentEditor: DocumentEditorComponent;

 public saveAsSfdt() :void {
let http: XMLHttpRequest = new XMLHttpRequest();'POST', 'http://localhost:5000/api/documenteditor/ExportSFDT');
http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
http.responseType = 'json';
let sfdt: any = { content: container.documentEditor.serialize() };

DocumentEditor object is available in DocumentEditorContainer component(DocumentEditor packaged with toolbar, statusbar & properties pane) as documentEditor