Watermark hidden by table

Dear all,

I would like to integrate a watermark into a word document. For this purpose I integrated the existing code snippet into my application. The watermark is fully shown on all pages that contain text only. If I insert tables into my word document, the watermark is hidden (fully or partial) by the table. Is there any way to avoid this behavior? I’m using Aspose.Words 6.0.1.0.

Thanks in advance

Erik

Hi

Thanks for your inquiry. Please attach your sample document and provide me code, you are using to insert watermark. I will check the issue and provide you more information.

Best regards.

Hi Alexey,

please find attached the required sample file. I have also a little issue with the Rotation property. If I use this property, the watermark is shown warped.

mDocumentBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
Shape shape = mDocumentBuilder.InsertImage(file);
shape.WrapType = WrapType.None;
shape.BehindText = true;
shape.Rotation = 45;
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.HorizontalAlignment = HorizontalAlignment.Center;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
shape.VerticalAlignment = VerticalAlignment.Center;

Thanks for your support.

Erik

Hi

Thank you for additional information. The problem occurs because your table has white background. To resolve the problem, you should just specify transparent background of this table. Please see the attached screenshot.

Hope this helps.

Best regards.

Hi Alexey,

thank you for that hint. The error source was an interface class for generating Aspose.Word Documents. There I used Color.White as standard value (instead of Color.Transparent).

But why looks the image so warped if I try to rotate it?

Regards

Erik

Hi

Thanks for your inquiry. It was a bug in older version of Aspose.Words, I suppose. I cannot reproduce this problem with the latest version. I used the following code for testing:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a table
for (int i = 0; i < 20; i++)
{
    for (int j = 0; j < 5; j++)
    {
        builder.InsertCell();
        builder.Write("this is text");
    }

    builder.EndRow();
}

builder.EndTable();

// Insert a watermark.
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
Shape shape = builder.InsertImage(@"Test001\watermark.JPG");
shape.WrapType = WrapType.None;
shape.BehindText = true;
shape.Rotation = 45;
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.HorizontalAlignment = HorizontalAlignment.Center;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
shape.VerticalAlignment = VerticalAlignment.Center;

// Save output document.
doc.Save(@"Test001\out.doc");

I also attached the output document, which was produced by this code.

You can download the latest version from here:

Best regards.

Hi Alexey,

I’m not able to use a more current version than 6.0.1.0. Our license file expired at the beginning of this year. Is there any hot fix available?

Thanks in advance

Erik

Hi

Thanks for your inquiry. You can try using another angle. For example try using -45 or 315 degrees. Hope this helps.

Best regards.

Hi Alexey,

it works fine if I use another angle. Thank you a lot!

Regards

Erik