Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Fri Apr 12, 2019 10:20 pm
Hi
What i want to do is to complete the the empty space of line with dashes(__) at the end of a paragraph
example
This is paragraph this is paragraph this is paragraph this is paragraph this is paragraph this is paragraph this is paragraph
this is paragraph this is paragraph this is paragraph this is paragraph this is paragraph this is paragraph this is paragraph
this is paragraph this is paragraph this is paragraph___________________________________________________________
Any suggestions
Thanks for reading.
-
BLITZKRIEG
-
- Posts: 6
- Joined: Fri Apr 12, 2019 10:05 pm
Mon Apr 15, 2019 10:50 am
Hello,
Thanks for your inquiry.
Please refer to the following sample code to achieve your demand. If there is any question, please provide your testing file to help us further look into it. You could send it to us via email (
support@e-iceblue.com).
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(@"test.docx");
foreach (Section section in doc.Sections)
{
foreach (Paragraph para in section.Paragraphs)
{
//change ' ' to '-'
string oldText = para.Text;
char[] charArray = oldText.ToCharArray();
for (int i = charArray.Length - 1; i >= 0; i--)
{
if (charArray[i] == ' ')
{
charArray[i] = '-';
}
else
{
break;
}
}
//append the new text
StringBuilder builder = new StringBuilder();
for (int i = 0; i < charArray.Length; i++)
{
builder.Append(charArray[i]);
}
//replace with new text
para.Replace(oldText, builder.ToString(), false, true);
}
}
doc.SaveToFile("result.docx", Spire.Doc.FileFormat.Docx2013);
Sincerely,
Lisa
E-iceblue support team
-
Lisa.Li
-
- Posts: 1261
- Joined: Wed Apr 25, 2018 3:20 am
Wed Apr 17, 2019 7:10 am
Hello,
Greetings from E-iceblue.
Did the code help you? Thanks in advance for your feedback and time.
Sincerely,
Lisa
E-iceblue support team
-
Lisa.Li
-
- Posts: 1261
- Joined: Wed Apr 25, 2018 3:20 am
Sat Apr 20, 2019 2:33 pm
Yes thank you it helped me a lot thank your team is awesome
-
BLITZKRIEG
-
- Posts: 6
- Joined: Fri Apr 12, 2019 10:05 pm
Mon Apr 22, 2019 1:44 am
Hello,
Thanks for your valuable feedback. If you need other helps, just feel free to contact us.
Wish you all the best!
Sincerely,
Lisa
E-iceblue support team
-
Lisa.Li
-
- Posts: 1261
- Joined: Wed Apr 25, 2018 3:20 am