Hello everyone, I'm copying some images from the internet and pasting them into the editor.
Some images generate the error "Argument is not image byte array" when trying to convert content in the backend to RTF format.
Steps to simulate:
1 - Access https://telemedicinamorsch.com.br/blog/interpretacao-da-mamografia and copy any image from page.
2 - Paste the image into the editor
3 - Send blob to backend using:
documentEditor.saveAsBlob("Docx")
4 - Try to convert wordDocument to RTF:
wordDocument.Save(memoryStream, WFormatType.Rtf);
|
Stream document = WordDocument.Save(data.content, FormatType.Rtf);
FileStream file = new FileStream("sample.rtf", FileMode.OpenOrCreate, FileAccess.ReadWrite);
document.CopyTo(file);
file.Close();
document.Close();
|
Hi Suriya, thank you for answering.
I tried to do the way you indicated but I wasn't successful, an exception occurred.
I created an example for you with 3 sfds, the first with the image copied from the website where the problem is happening and the second is just text and the third an image copied from the Syncfusion website. Only the first sfdt that throws an exception.
|
public string ExportSFDT([FromBody] SaveParameter data)
{ string name = data.FileName; string format = RetrieveFileType(name); if (string.IsNullOrEmpty(name)) { name = "Document1.doc"; } Stream document = WordDocument.Save(data.Content, FormatType.Docx); string path = _hostingEnvironment.ContentRootPath + "\\App_Data\\Server-sfdt-exporting.docx";
FileStream file = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); WDocument dociodocument = new WDocument(document, WFormatType.Docx); dociodocument.Save(file, WFormatType.Docx);
file.Position = 0; file.Close(); document.Close(); return ""; //return SaveDocument(document, format, name); } |