Add a watermark

Apr 6, 2016 at 4:27 PM
i am trying to add a watermark however i wasnt able, i thought of adding an image with rotation however i don't know how to,
a. set image text wrap to be behind text
b. fix image location

please help me to do so


thanks in advance
Developer
Apr 6, 2016 at 4:30 PM
Not sure what watermark means in your case bun in Examples you have this code. It adds 2 images. One normal way, one with rotation.
   /// <summary>
    /// Create a document with two pictures. One picture is inserted normal way, the other one with rotation
    /// </summary>
static void HelloWorldAddPictureToWord() {
Console.WriteLine("\tHelloWorldAddPictureToWord()");

// Create a document.
using (DocX document = DocX.Create(@"docs\HelloWorldAddPictureToWord.docx"))
{
    // Add an image into the document.    
    RelativeDirectory rd = new RelativeDirectory(); // prepares the files for testing
    rd.Up(2); 
    Image image = document.AddImage(rd.Path + @"\images\logo_template.png");

    // Create a picture (A custom view of an Image).
    Picture picture = image.CreatePicture();
    picture.Rotation = 10;
    picture.SetPictureShape(BasicShapes.cube);

    // Insert a new Paragraph into the document.
    Paragraph title = document.InsertParagraph().Append("This is a test for a picture").FontSize(20).Font(new FontFamily("Comic Sans MS"));
    title.Alignment = Alignment.center;

    // Insert a new Paragraph into the document.
    Paragraph p1 = document.InsertParagraph();

    // Append content to the Paragraph
    p1.AppendLine("Just below there should be a picture ").Append("picture").Bold().Append(" inserted in a non-conventional way.");
    p1.AppendLine();
    p1.AppendLine("Check out this picture ").AppendPicture(picture).Append(" its funky don't you think?");
    p1.AppendLine();

    // Insert a new Paragraph into the document.
    Paragraph p2 = document.InsertParagraph();
    // Append content to the Paragraph.

    p2.AppendLine("Is it correct?");
    p2.AppendLine();

    // Lets add another picture (without the fancy stuff)
    Picture pictureNormal = image.CreatePicture();

    Paragraph p3 = document.InsertParagraph();
    p3.AppendLine("Lets add another picture (without the fancy  rotation stuff)");
    p3.AppendLine();
    p3.AppendPicture(pictureNormal);

    // Save this document.
    document.Save();
    Console.WriteLine("\tCreated: docs\\HelloWorldAddPictureToWord.docx\n");
}
}