We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Watermark Alignment to Left Margin

Hi there,
I have been trying for ages but no matter what combination of alignments I use I cannot get the watermark text to vertically align to Left Margin of the document. Does anyone have some sample code on how to do this?
Many Thanks James

Hi James,

Thanks for your inquiry. We need to understand the real situation what exactly you’re trying to implement. Could you please attach your expected Word document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will investigate the scenario on our end and provide you code to achieve the same output using Aspose.Words.

Best regards,

Hi again,

thanks for the reply. A sample word document is attached showing where I how I would like the watermark to be aligned.

Many thanks, James

Hi James,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi James,

Thanks for being patient. Please check the modified version of code (taken from this article) to meet your requirement.


/// Inserts a watermark into a document.


/// The input document.

/// Text of the watermark.

private static void InsertWatermarkText(Document doc, string watermarkText)


// Create a watermark shape. This will be a WordArt shape.

// You are free to try other shape types as watermarks.

Shape watermark = new Shape(doc, ShapeType.TextPlainText);

// Set up the text of the watermark.

watermark.TextPath.Text = watermarkText;

watermark.TextPath.FontFamily = "Arial";

watermark.Height = 22;

watermark.Width = 471;

// Text will be directed from the bottom to the top.

watermark.Rotation = 270;

watermark.Fill.Color = Color.Red;

watermark.StrokeColor = Color.Red;

watermark.Left = -205.8;

watermark.Top = 399;

watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.LeftMargin;

watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;

watermark.WrapType = WrapType.None;

// Create a new paragraph and append the watermark to this paragraph.

Paragraph watermarkPara = new Paragraph(doc);


// Insert the watermark into all headers of each document section.

foreach (Section sect in doc.Sections)


// There could be up to three different headers in each section, since we want

// the watermark to appear on all pages, insert into all headers.

InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);

InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);

InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);



private static void InsertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, HeaderFooterType headerType)


HeaderFooter header = sect.HeadersFooters[headerType];

if (header == null)


// There is no header of the specified type in the current section, create it.

header = new HeaderFooter(sect.Document, headerType);



// Insert a clone of the watermark into the header.



I hope, this helps.

Best regards,

Hi Awais,
many thanks for that, it works a treat.
Cheers james