Pete
Pete

Reputation: 113

Need signature line to appear on same line as printed name open xml sdk 2.5 - Enter Text Based on Tab position

I was wondering if anyone out there could assist with this question. I've reflected the code of a Word Document using the Open XML SDK 2.5 Productivity Tool. However, I'm having trouble editing the code to get a signature line on the same line as a user's typed name. So I want this:

Joe Blow          ______________________
Larry Star        ______________________

etc. I want the signature lines the same length.

Of course I can justify paragraphs but this will not keep things on the same line. What I'd like to do is go to a certain tab position and draw the line but I'm not sure how to do this.

Can anyone assist with this?

I was able to figure this out. Below is the open xml SDK C# code to add text at specific tab position. Hope it helps someone else.

 Paragraph paragraph52 = new Paragraph() { RsidParagraphAddition = "00736172", RsidRunAdditionDefault = "00736172", ParagraphId = "359EF518", TextId = "77777777" };

            ParagraphProperties paragraphProperties52 = new ParagraphProperties();

            Run run28 = new Run();
            Text text26 = new Text() { Space = SpaceProcessingModeValues.Preserve };

            if (oversight.Lead == null)
            {
                text26.Text = "";
            }
            else
            {
                text26.Text = "Joe Blow - Manager";
            }

            run28.Append(text26);

            Run run29 = new Run();
            TabChar tabChar1 = new TabChar();
            run29.Append(tabChar1);

            Tabs tabs2 = new Tabs();
            TabStop tabStop2 = new TabStop() { Val = TabStopValues.Left, Position = 5025 };
            tabs2.Append(tabStop2);
            paragraphProperties52.Append(tabs2);

            Run run30 = new Run();

            Text text27 = new Text(); 

            if (oversight.Lead == null)
            {
                text27.Text = "";
            }
            else
            {
                text27.Text = " ______________________________";
            }

            run30.Append(text27);

            paragraph52.Append(paragraphProperties52);
            paragraph52.Append(run28);
            paragraph52.Append(run29);
            paragraph52.Append(run30);

Upvotes: 0

Views: 601

Answers (1)

Pete
Pete

Reputation: 113

I was able to figure this out. Below is the open xml SDK C# code to add text at specific tab position. Hope it helps someone else.

 Paragraph paragraph52 = new Paragraph() { RsidParagraphAddition = "00736172", RsidRunAdditionDefault = "00736172", ParagraphId = "359EF518", TextId = "77777777" };

            ParagraphProperties paragraphProperties52 = new ParagraphProperties();

            Run run28 = new Run();
            Text text26 = new Text() { Space = SpaceProcessingModeValues.Preserve };

            if (oversight.Lead == null)
            {
                text26.Text = "";
            }
            else
            {
                text26.Text = "Joe Blow - Manager";
            }

            run28.Append(text26);

            Run run29 = new Run();
            TabChar tabChar1 = new TabChar();
            run29.Append(tabChar1);

            Tabs tabs2 = new Tabs();
            TabStop tabStop2 = new TabStop() { Val = TabStopValues.Left, Position = 5025 };
            tabs2.Append(tabStop2);
            paragraphProperties52.Append(tabs2);

            Run run30 = new Run();

            Text text27 = new Text(); 

            if (oversight.Lead == null)
            {
                text27.Text = "";
            }
            else
            {
                text27.Text = " ______________________________";
            }

            run30.Append(text27);

            paragraph52.Append(paragraphProperties52);
            paragraph52.Append(run28);
            paragraph52.Append(run29);
            paragraph52.Append(run30);

Also, don't forget to append the paragraph to the body:

 body1.Append(paragraph52);

Upvotes: 1

Related Questions