Free Support Forum - aspose.com

Watermark is a link

Hi,

If I put a watermark on a document which contains a url (see attached example) it automatically creates a clickable hyperlink in the watermark.

I would like to avoid this, is there any property that can negate this feature?

Thanks

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words for .NET (10.2.0) and the code from this thread:

Please see the attached document.

Best regards,

Hi,

What was the watermark text that you placed - notice that the text I put was "www.aspose.com" which causes the link not just words.

Is this what you tried and didn't reproduce?

Thanks !

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thanks for your request. Yes, I tried with this url and cannot reproduce the problem. Here is the code I used:

Document doc = new Document();

InsertWatermarkText(doc, "www.aspose.com");

doc.Save(@"Test001\out.pdf");

Also, I attached the output document produced by this code.

Best regards,

Hi


I’ve found the solution to this issue - adobe reader has a preference you can set for pdf’s
“Create links from URL’s” which causes any url to turn to links including any in the watermark.

Do you know of a way to disable this?

thanks

Hi

Thanks for your request. It seems it is Adobe Acrobat options. There is no way to control it using Aspose.Words.

Best regards,

Hi there,

Thanks for your inquiry.

As long as your using Aspose.Words for .NET 9.7 or above you can use the ShapeRenderer class to render the watermark as an image. This should prevent Adobe Acrobat from detecting the text and displaying it as a link. Please see the code here for an example.

// Create a new paragraph and append the watermark to this paragraph.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Paragraph watermarkPara = new Paragraph(doc);

watermarkPara.AppendChild(watermark);

// Render the watermark as an image and insert it in place of the text watermark.

Stream watermarkAsImage = new MemoryStream();

watermark.GetShapeRenderer().Save(watermarkAsImage, null);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveTo(watermarkPara);

Shape imageShape = builder.InsertImage(watermarkAsImage);

imageShape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;

imageShape.RelativeVerticalPosition = RelativeVerticalPosition.Page;

imageShape.WrapType = WrapType.None;

imageShape.VerticalAlignment = VerticalAlignment.Center;

imageShape.HorizontalAlignment = HorizontalAlignment.Center;

// Make sure the watermark comes out on front of the image.

imageShape.ZOrder = 2;

// Remove the old watermark.

watermark.Remove();

// 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);

}

Also the discussion near the end of the page in this thread here may also be helpful to you.

If we can help with anything else, please feel free to ask.

Thanks,