none
Unable to adjust paragraph alignment

    Question

  • So I'm trying to open a word document and replace a block of text in the bottom right side of the first page with a picture. I am able to replace the image, but it is not positioned the way I want it to be. Changing the frame properties/paragraph properties doesn't seem to help. Is there another approach that I seem to be missing?

        if (text.Text == "text match")
                    {
                      paragraph.RemoveAllChildren();
                      ParagraphProperties paraProp = new ParagraphProperties
                      {
                        KeepNext = new KeepNext(),
                        FrameProperties = new FrameProperties
                        {
                          HeightType = HeightRuleValues.Auto,
                          VerticalPosition = VerticalAnchorValues.Page,
                          HorizontalPosition = HorizontalAnchorValues.Page,
                          XAlign = HorizontalAlignmentValues.Right,
                          YAlign = VerticalAlignmentValues.Bottom
                        }
                      };
                      paragraph.ParagraphProperties = paraProp;
                      paragraph.Append(new Run(element.CloneNode(true)));
                      break;
                    }

    Edit: I forgot to mention, this block is running in a large nested foreach loop iterating through every text in every run in every paragraph. In this context, paragraph is the current paragraph.


    mercredi 9 mai 2018 22:14

Réponses

  • Problem solved. I was using an inline image rather than an anchor. By switching to anchor and messing around with simplepos I was able to achieve the desired position.
    • Marqué comme réponse emsimpson92 jeudi 17 mai 2018 15:05
    jeudi 17 mai 2018 15:05

Toutes les réponses

  • Hello emsimpson92,

    >> I am able to replace the image, but it is not positioned the way I want it to be. 

    How do you want to position the image? Could you please detail us your design? I could not get enough information to reproduce your issue. Are you looping in a table with nested tables?

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    jeudi 10 mai 2018 07:33
    Modérateur
  • There is a textbox in the bottom right of the template file. I'm able to remove the text from the textbox and paste the image into the box itself, but changing its positioning causes it to get cut off when it reaches the edges of the text box. I've tried appending paragraphs before and after the box and pasting the picture in there, but when I do that I am unable to reposition the image at all. Should I be adjusting the image offset?

    All I want to do is have a watermark in the bottom right hand corner of the first page. It's a multi page document so appending to the body doesn't work either.

    Update: I'm under the impression that my image needs to be part of the anchor class rather than the inline class. I'm not really sure what I'm doing here, but for now I'm working on trying to figure out how to setup SimplePos. I think I'm on the right track.

    jeudi 10 mai 2018 22:58
  • Hello emsimpso92,

    What's the text box? Is a text box shape or a text box content control? Could you please share us some screenshots to show us what's the result you want and what's the current result you got. 

    Besides, I would suggest you share us the whole code you used(including the code replacing the image) so we could got more idea of your design.

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    vendredi 11 mai 2018 05:20
    Modérateur
  • Hello emsimpson92,

    What's the current state of your issue? I note that you have ever replied to the thread but deleted. Does your issue resolved?

    If yes, I would suggest you share your solution and mark it as answer to help other developers who runs into the same issue.

    If not, I would suggest you share a simply document directly for us to test. I do fail to move a text content control to the bottom and right of the page. May it be a picture control?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    mardi 15 mai 2018 02:04
    Modérateur
  • Problem solved. I was using an inline image rather than an anchor. By switching to anchor and messing around with simplepos I was able to achieve the desired position.
    • Marqué comme réponse emsimpson92 jeudi 17 mai 2018 15:05
    jeudi 17 mai 2018 15:05