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.

Sun May 02, 2021 12:12 pm

Hello,

I came here to ask if it's possible to put text with different style on a same line ?

What I try to accomplish is to write a character with the Segoe UI Emoji font, so an emoji, and just after it a text with Arial font.

My problem is when I put two paragraphs right to each other, even without any line break, the second one is put below the first.

Is there any way to do what I try to accomplish ? Two text with different styles right after one another.

I hope I was clear enough !

Thanx a lot :)

AdrienDji
 
Posts: 2
Joined: Sun May 02, 2021 11:59 am

Mon May 03, 2021 9:26 am

Hello,

Thanks for your inquiry.
Please refer to the following code to achieve your requirements. If there are any questions, just feel free to contact us.
Code: Select all
            Document doc = new Document();
            Paragraph para = doc.AddSection().AddParagraph();
            TextRange range1 = para.AppendText("your emoji");
            range1.CharacterFormat.FontName = "Segoe UI Emoji";
            TextRange range2 = para.AppendText("hello");
            range2.CharacterFormat.FontName = "Arial";
            doc.SaveToFile("result.docx",FileFormat.Docx);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon May 03, 2021 9:57 am

Thanx a lot Rachel.

I've made it work differently by using the HTML input just now, but I'll keep your solution in mind :)

AdrienDji
 
Posts: 2
Joined: Sun May 02, 2021 11:59 am

Mon May 03, 2021 10:16 am

Hello,

Thanks for your reply.
If you have any other questions, just feel free to contact us.
Wish you all the best!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc