6 Answers, 1 is accepted
0
Hi Stefania,
The RadEditro's content always returns String value. Therefore, the answer is to convert the string into a byte array.
This on other hand is a general .NET matter. I suggest looking for the answer in public forums and MSDN resources related to general C# or VB techniques. After a quick search, I found this thread, which might help you continue further your research--How to convert the string to byte in c# (https://social.msdn.microsoft.com/Forums/vstudio/en-US/08e4553e-690e-458a-87a4-9762d8d405a6/how-to-convert-the-string-to-byte-in-c-).
Regards,
Ianko
Telerik
The RadEditro's content always returns String value. Therefore, the answer is to convert the string into a byte array.
This on other hand is a general .NET matter. I suggest looking for the answer in public forums and MSDN resources related to general C# or VB techniques. After a quick search, I found this thread, which might help you continue further your research--How to convert the string to byte in c# (https://social.msdn.microsoft.com/Forums/vstudio/en-US/08e4553e-690e-458a-87a4-9762d8d405a6/how-to-convert-the-string-to-byte-in-c-).
Regards,
Ianko
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Mattia
Top achievements
Rank 2
answered on 13 Mar 2015, 10:52 AM
Hi,
I tried to do this:
On save button
and then in my webservice
When I open the .docx this is the result
.....
/>
I tried to do this:
<
telerik:RadEditor
ID
=
"editor1"
runat
=
"server"
EditModes
=
"Design"
> </
telerik:RadEditor
>
On save button
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] docBytes = encoding.GetBytes(editor1.Content);
myService.Save(docByte);
and then in my webservice
using
(FileStream fs =
new
FileStream(GetAttachmentsPath() + filename, FileMode.Create))
{
fs.Write(docBytes.Value, 0, docBytes.Value.Length);
fs.Flush();
fs.Close();
}
When I open the .docx this is the result
<
p
>Test</
p
>
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0IAAAGxCAIAAADApZG9AAAgAElEQVR4nOy951cbWZ+oW/wjZ635fmbds9a5E87MOXfunZlzXrvfxn6N3+7pZLcjtrvdbrvd3QZjY4IDwQknMtjkKAQiCUlVKglEEkESSQEkIZSIygE86H6ooFIpAzbQ3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GOqe4S2ZtTkrv/beref1fWp86yXsx2FOgY6UN5f0Uzjow+/UbLvC/pLBVzmsVIxwTCHO9rpJYzzmseQ9pHkQ5o35sPAPgUABoHAAAAB5O4NG6Q3zvFa5I05fY++BLNOrJQdmajK13fW6DilE9zqye4DUMchojfO8hnjyPMub5KcV0m/PJqT97Z3rxzotJfpxiPldxKWV8159WNgaw/Td392+m7/1X04HNezjdwzleiB38eyviXoXv/S5T5b4KcJFb+ZWHdEzm3eqGvZLwmA8HKyT8nKv11mpGv6quQ9VVD+958AMCnANA4AAAAOJjEpXFD/N4pXpO0JZ+b+x2afXTiWdJcxaWpujRJa76kq0TCqx9DmINozzC/c7K3aqr+7mDB6dFX56RlVyWlP4qefDtRckXR+kDRVylrfih7dnL67t/Opv/XhdKzqppfVTU3dW8vTDz8t5F7/3My76i6
.....
/>
0

Mattia
Top achievements
Rank 2
answered on 16 Mar 2015, 09:53 AM
Hi,
I found the solution but I still have a problem with the copy and pasted image
etc...
I tried on your demo and it seems there is the same problem
http://demos.telerik.com/aspnet-ajax/editor/examples/import-export/docx-import-export/defaultcs.aspx
When you open the exported docx the image is 1px * 1px
How can I keep the right size of the image?
Thanks
I found the solution but I still have a problem with the copy and pasted image
private
Byte[] contentEditor ;
protected
void
editor1_ExportContent(
object
sender, EditorExportingArgs e)
{
ExportType exportType = e.ExportType;
if
(exportType == ExportType.Word)
{
string
exportedOutput = e.ExportOutput;
Byte[] output = Encoding.Default.GetBytes(exportedOutput);
DocxFormatProvider docxProvider =
new
DocxFormatProvider();
RadFlowDocument document = docxProvider.Import(output);
Header defaultHeader = document.Sections.First().Headers.Add();
Paragraph defaultHeaderParagraph = defaultHeader.Blocks.AddParagraph();
defaultHeaderParagraph.TextAlignment = Alignment.Right;
defaultHeaderParagraph.Inlines.AddRun(
"This is a sample header."
);
Footer defaultFooter = document.Sections.First().Footers.Add();
Paragraph defaultFooterParagraph = defaultFooter.Blocks.AddParagraph();
defaultFooterParagraph.TextAlignment = Alignment.Right;
defaultFooterParagraph.Inlines.AddRun(
"This is a sample footer."
);
contentEditor = docxProvider.Export(document);
}
e.Cancel =
true
;
}
protected
void
SendButton_Click(
object
sender, EventArgs e)
{
Dictionary<
string
,
byte
[]> files =
new
Dictionary<
string
,
byte
[]>();
editor1.ExportToDocx();
files.Add(editor1.ExportSettings.FileName+
".docx"
, contentEditor);
myService.Save(...);
}
I tried on your demo and it seems there is the same problem
http://demos.telerik.com/aspnet-ajax/editor/examples/import-export/docx-import-export/defaultcs.aspx
When you open the exported docx the image is 1px * 1px
How can I keep the right size of the image?
Thanks
0
Hi Stefania,
On my end exporting of images occurs as expected.
It would be helpful if you could provide more details about the the source of the pasted images, how it is pasted, and if possible to described the problem in steps, so to be able to accurately understand the situation.
Regards,
Ianko
Telerik
On my end exporting of images occurs as expected.
It would be helpful if you could provide more details about the the source of the pasted images, how it is pasted, and if possible to described the problem in steps, so to be able to accurately understand the situation.
Regards,
Ianko
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Mattia
Top achievements
Rank 2
answered on 16 Mar 2015, 01:35 PM
This is what I'm doing:
- Press "stamp" on the keyboard
- CTRL+V on the demo
or instead of "stamp" button using the window capture instrument and then press the copy button
- Export docx
- open the saved file with word 2003 and 2007
- Press "stamp" on the keyboard
- CTRL+V on the demo
or instead of "stamp" button using the window capture instrument and then press the copy button
- Export docx
- open the saved file with word 2003 and 2007
0
Hello Stefania,
Thank you for getting back with these details.
The encountered situation is more or less expected. The browser can render the base64 image with proper size. Although, MS Word content needs specific width and height values to render the image.
Therefore, a possible solution is to implement either
Regards,
Ianko
Telerik
Thank you for getting back with these details.
The encountered situation is more or less expected. The browser can render the base64 image with proper size. Although, MS Word content needs specific width and height values to render the image.
Therefore, a possible solution is to implement either
- a custom filter that adds proper width and height to all images (enabling the ConvertInlineStylesToAttributes filter might help you);
- or use a custom event handler attached to the OnClientSubmit event, which handles the width and height attributes.
Regards,
Ianko
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.