Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tab Stops to Word Paragraphs #117

Merged
merged 16 commits into from
Mar 4, 2023
Merged

Add Tab Stops to Word Paragraphs #117

merged 16 commits into from
Mar 4, 2023

Conversation

PrzemyslawKlys
Copy link
Member

@PrzemyslawKlys PrzemyslawKlys commented Feb 28, 2023

This PR:

internal static void Example_BasicTabStops(string folderPath, bool openWord) {
    Console.WriteLine("[*] Creating standard document with paragraphs");
    string filePath = System.IO.Path.Combine(folderPath, "Basic Document with some tab stops.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph = document.AddParagraph("\tFirst Line");

        document.Settings.DefaultTabStop = 2880;
        document.Settings.CharacterSpacingControl = CharacterSpacingValues.DoNotCompress;

        Console.WriteLine("Tabs count: " + paragraph.TabStops.Count);

        var tab1 = paragraph.AddTabStop(1440);

        var tab2 = paragraph.AddTabStop(1440);
        tab2.Alignment = TabStopValues.Left;
        tab2.Leader = TabStopLeaderCharValues.Hyphen;
        tab2.Position = 1440;

        paragraph.AddText("\tMore text");

        Console.WriteLine($"Tabs count: " + paragraph.TabStops.Count);

        var paragraph1 = document.AddParagraph("\tNext Line");

        var tab3 = paragraph1.AddTabStop(5000);
        tab3.Leader = TabStopLeaderCharValues.Hyphen;

        var tab4 = paragraph1.AddTabStop(1440 * 2);
        paragraph1.AddText("\tEven more text");

        Console.WriteLine("Tabs for Paragraph2 count: " + paragraph.TabStops.Count);
        Console.WriteLine("Tabs for Paragraph1 count: " + paragraph1.TabStops.Count);
        Console.WriteLine("Default tab stop: " + document.Settings.DefaultTabStop);
        Console.WriteLine("Default tab stop: " + document.Settings.CharacterSpacingControl);

        document.Save();
    }

    using (WordDocument document = WordDocument.Load(filePath)) {

        document.Save(openWord);
    }
}

@PrzemyslawKlys PrzemyslawKlys marked this pull request as draft March 3, 2023 21:32
@PrzemyslawKlys PrzemyslawKlys marked this pull request as ready for review March 4, 2023 22:35
@PrzemyslawKlys PrzemyslawKlys merged commit 794a139 into master Mar 4, 2023
@PrzemyslawKlys PrzemyslawKlys deleted the TabStops branch March 13, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to adjust or create tab stops on WordParagraph objects
1 participant