This project has moved. For the latest updates, please go here.

Formatting within a sentence?

Sep 25, 2015 at 3:13 PM
Hi,
I have no problem creating documents consisting of many paragraphs of different styles (should I want to!). What I need to be able to do is to create a single paragraph that itself has several styles.

For example, with the following sentence I might want to:

The quick brown jumps over the lazy dogs;

I might want the bold and italic as shown the the word 'brown' coloured brown.

How do I do this?

Cheers.
Oct 14, 2015 at 9:14 PM
I would like to know this as well.

Thanks!
Developer
Oct 14, 2015 at 9:26 PM
One of the ways
    static void HelloWorldAdvancedFonts()
    {
        Console.WriteLine("\tHelloWorldAdvancedFonts()");
        // Create a document.
        using (DocX document = DocX.Create(@"docs\Hello World Advanced Fonts.docx"))
        {
            // Insert a new Paragraphs.
            Paragraph p = document.InsertParagraph();

            p.Append("I am ").Append("bold").Bold()
            .Append(" and I am ")
            .Append("italic").Italic().Append(".")
            .AppendLine("I am ")
            .Append("Arial Black")
            .Font(new FontFamily("Arial Black"))
            .Append(" and I am not.")
            .AppendLine("I am ")
            .Append("BLUE").Color(Color.Blue)
            .Append(" and I am")
            .Append("Red").Color(Color.Red).Append(".");

            // Save this document.
            document.Save();
            Console.WriteLine("\tCreated: docs\\Hello World Advanced Fonts.docx\n");
        }// Release this document from memory.
    }
Marked as answer by MadBoy on 11/21/2015 at 5:41 AM
Oct 14, 2015 at 10:43 PM
Ok, I did that, but now I want the whole paragraph to be size 24. If I tag .FontSize(24) on the end, it just does the last segment. How can I apply that to the whole paragraph?
Developer
Nov 21, 2015 at 1:40 PM
Just do this per line. For each append you need to this. Sorry for being so late, kind of missed it.