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 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.
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.
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.
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?
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.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.