My first paragraph.
byte[] byteArray = Encoding.ASCII.GetBytes(html);
using (var stream = new MemoryStream(byteArray))
{
Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Html);
using (var saveStream = new MemoryStream())
{
document.Save(saveStream, FormatType.Docx);
document.Close();
Syncfusion.EJ2.DocumentEditor.WordDocument wdocument = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(saveStream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(wdocument);
wdocument.Dispose();
return sfdt;
}
} |
Hi James,Thank you for contacting the Synfusion support.Using Syncfusion DocIO, you can convert the Html Document to Sfdt and load the sample DocumentEditor.Please check below sample code for reference.
byte[] byteArray = Encoding.ASCII.GetBytes(html);using (var stream = new MemoryStream(byteArray)){Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Html);using (var saveStream = new MemoryStream()){document.Save(saveStream, FormatType.Docx);document.Close();Syncfusion.EJ2.DocumentEditor.WordDocument wdocument = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(saveStream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(wdocument);wdocument.Dispose();return sfdt;}}Please check the below sample for reference which is in ASP.NET MVC.Please let me know if you have any questions.Regards,Suriya M.
_document = new WordDocument();
_section = _document.AddSection();
_paragraph = _section.AddParagraph();
_paragraph.ParagraphFormat.HorizontalAlignment = styleOptions.Alignment;
_paragraph.ParagraphFormat.BeforeSpacing = styleOptions.TopSpace;
var textRange = _paragraph.AppendText(text);
textRange.CharacterFormat.Font = new Font(styleOptions.FontFamily, styleOptions.FontSize, styleOptions.FontStyle, GraphicsUnit.Pixel, new byte());
using (var stream = new MemoryStream())
{
_document.Save(stream, FormatType.Docx);
_document.Close(); var document = new WordDocument();
document.Open(stream, FormatType.Automatic); string sfdt = JsonConvert.SerializeObject(document); <----This line throws the exception with message "Error getting value from 'Font' on 'Syncfusion.DocIO.DLS.WCharacterFormat'."
response.Document = sfdt;
}
using (var stream = new MemoryStream()) { _document.Save(stream, FormatType.Docx); _document.Close(); var document = new WordDocument(); document.Open(stream, FormatType.Automatic); string sfdt = JsonConvert.SerializeObject(document); |
Syncfusion.EJ2.DocumentEditor.WordDocument wdocument = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(saveStream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(wdocument);
wdocument.Dispose();
|
Hi, i am getting the same issue and I am trying to use the example but I don't find the class
Syncfusion.EJ2.DocumentEditor.WordDocument , only find
Syncfusion.DocIO.DLS.WordDocument
can you help me with some idea?
I'm working with .net framework 4.0 and asp.net web forms
thanks
Hi Halber,
##i am getting the same issue and I am trying to use the example but I don't find the class
Syncfusion.EJ2.DocumentEditor.WordDocument
We are suspecting that you have not downloaded the document editor NuGet package in your project. Please refer the below documentation for reference
Please let us know if you need any further assistance
Regards,
Dhanush Sekar
Hi Halber,
Please install the below nuget to get out of this issue "I don't find the class Syncfusion.EJ2.DocumentEditor.WordDocument ":
https://www.nuget.org/packages/Syncfusion.Ej2.Wordeditor.ASPNet.Core/
Documentation:
https://ej2.syncfusion.com/aspnetcore/documentation/document-editor/import
Note: If this post is helpful, please mark it as an answer so that other members can locate it more quickly.
Please let us know if you need any further assistance.
Regards,
Suriya M.