none
Add Watermark in Word Document using VSTO 2010 with C# RRS feed

  • Question

  • Hello,

    I want to add watermark in word Document as written below using VSTO 2010 with C#.  Watermark contains two lines which I want to show as diagonal.

    THIS IS A CONFIDENTIAL DOCUMENT, APPROVAL IS REQUIRED TO XXXXXXXXXXXXXXXXX

    AUTHOR: <Author Name>,  DATE:<14 - June - 2015>

     I found one below link but how can I put it in two lines i.e. caveat in one line & author & date detail in next lines. Please suggest some code snippets or links which are useful in this context. Also how can I increase the font size of the watermark?

    http://blogs.msdn.com/b/pstubbs/archive/2005/03/07/387170.aspx

    Thanks

    Please copy some code snippets or links which I can refer for this.
    Please copy some code snippets or links which I can refer for this.
    Please copy some code snippets or links which I can refer for this.
    Sunday, June 14, 2015 8:13 AM

Answers

  • Hi Pushkar

    All you need to do is add a "new line" character at the position you want the line break to occur. For example:

    string msg = "THIS IS A CONFIDENTIAL DOCUMENT, APPROVAL IS REQUIRED TO XXXXXXXXXXXXXXXXX\rAUTHOR: <Author Name>,  DATE:<14 - June - 2015>";

    Note the \r

    For the font, using the sample code as the basis of the object variable name:

    wmShape.TextFrame.TextRange.Font.Size = 18f;


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by L.HlModerator Wednesday, June 24, 2015 11:51 PM
    Sunday, June 14, 2015 5:59 PM
    Moderator