I got a trouble about saving .docx file from a richtextbox by writing a C# program with spire.Doc.
The follows are my codes for this program, after debugging, the window form will hang on.
Document doc = new Document();
//Add Section
//Section section = doc.AddSection();
//Add Paragraph
//Paragraph Para = section.AddParagraph();
//Append Text
//Para.AppendRTF(richTextBox1.Rtf);
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Word *.docx|*.docx";
saveFileDialog1.Title = "Save an Word File";
saveFileDialog1.ShowDialog();
string filename=saveFileDialog1.FileName;
if(filename!="")
{
doc.SaveToFile(filename, FileFormat.Docx);
System.Diagnostics.Process.Start(filename);
}
Also, I try another method to write RTF content into a .docx file, but the .docx will show garbled text(for Chinese words):
Document doc = new Document();
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Word *.docx|*.docx";
saveFileDialog1.Title = "Save an Word File";
saveFileDialog1.ShowDialog();
string filename=saveFileDialog1.FileName;
if(filename!="")
{
richTextBox1.SaveFile(@"temp.rtf", RichTextBoxStreamType.RichText);
doc.LoadRtf(@"temp.rtf");
doc.SaveToFile(filename, FileFormat.Docx);
System.Diagnostics.Process.Start(filename);
}
Please help fix the problems above, thanks a lot !!