Free Support Forum - aspose.com

Watermark move the text in file

Hi,


I try to watermark a file with this code:
Aspose.Words.Drawing.Shape watermark = new Aspose.Words.Drawing.Shape(doc, Aspose.Words.Drawing.ShapeType.TextPlainText);

// Set up the text of the watermark.
watermark.TextPath.Text = watermarkText;
watermark.TextPath.FontFamily = “Arial”;
watermark.Width = 500;
watermark.Height = 20;

watermark.Rotation = 0;
watermark.VerticalAlignment = Aspose.Words.Drawing.VerticalAlignment.Top;
watermark.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
watermark.Fill.Color = System.Drawing.Color.Red;
watermark.StrokeColor = System.Drawing.Color.Red;

watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;

Aspose.Words.Paragraph watermarkPara = new Aspose.Words.Paragraph(doc);
watermarkPara.AppendChild(watermark);

// Insert the watermark into all headers of each document section.
foreach (Aspose.Words.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);
}

public static void InsertWatermarkIntoHeader(Aspose.Words.Paragraph watermarkPara, Aspose.Words.Section sect, HeaderFooterType headerType)
{
Aspose.Words.HeaderFooter header = sect.HeadersFooters[headerType];

if (header == null)
{
// There is no header of the specified type in the current section, create it.
header = new Aspose.Words.HeaderFooter(sect.Document, headerType);
sect.HeadersFooters.Add(header);
}

// Insert a clone of the watermark into the header.
header.AppendChild(watermarkPara.Clone(true));
}


The watermark is present by it insert a backline so its change the file presentation. See the files attached.

Can you help me??

Regards,
Laurent


Hi Laurent,

Thanks for your inquiry. In your case, we suggest you please change the font size of paragraph that contains the watermark to get the desired output. Hope this helps you.

Aspose.Words.Paragraph watermarkPara = new Aspose.Words.Paragraph(doc);

watermarkPara.ParagraphBreakFont.Size = 1;

watermarkPara.AppendChild(watermark);

Hello,


Thanks for your reply.

Its working.

Have a nice day,

Sincerely,

Laurent
Hi Laurent,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.