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

Free Support Forum - aspose.com

Watermarks on word doc not coming across on tiff conversion

I have a word doc that I am applying a watermark to. If I print the word doc directly, it shows up. When I run it thru a tiff converter the watermark is not there. Pls help.
Code following:

Protected Sub btnWatermk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatermk.Click
Dim doc As New Document("C:\Data\Test1.doc")
InsertWatermarkText(doc, "CONFIDENTIAL")
Dim options As New ImageSaveOptions(SaveFormat.Tiff)
options.TiffCompression = TiffCompression.Ccitt4
doc.Save("C:\Data\TestWMk.tiff", options)
’ Dim opt2 As New ImageSaveOptions(SaveFormat.)
’ doc.Save("C:\Data\TestWMk.pdf", opt2)
'Catch ex As Exception
’ lblIncrement.Text = ex.Message
'End Try
End Sub

Protected Sub InsertWatermarkText(ByVal doc As Document, ByVal watermarkText As String)
’ Create a watermark shape. This will be a WordArt shape. 
’ You are free to try other shape types as watermarks.
Dim watermark As New Shape(doc, ShapeType.TextPlainText)

’ Set up the text of the watermark.
watermark.TextPath.Text = watermarkText
watermark.TextPath.FontFamily = "Arial"
watermark.Width = 500
watermark.Height = 100
’ Text will be directed from the bottom-left to the top-right corner.
watermark.Rotation = -40
’ Remove the following two lines if you need a solid black text.
watermark.Fill.Color = System.Drawing.Color.Gray ’ Try LightGray to get more Word-style watermark
watermark.StrokeColor = System.Drawing.Color.Gray ’ Try LightGray to get more Word-style watermark

’ Place the watermark in the page center.
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page
watermark.WrapType = WrapType.None
watermark.VerticalAlignment = VerticalAlignment.Center
watermark.HorizontalAlignment = HorizontalAlignment.Center

’ Create a new paragraph and append the watermark to this paragraph.
Dim watermarkPara As New Paragraph(doc)

’ Insert the watermark into all headers of each document section.
For Each sect As Section 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)
Next sect

End Sub

Private Shared Sub InsertWatermarkIntoHeader(ByVal watermarkPara As Paragraph, ByVal sect As Section, ByVal headerType As HeaderFooterType)
Dim header As HeaderFooter = sect.HeadersFooters(headerType)

If header Is Nothing Then
’ There is no header of the specified type in the current section, create it.
header = New HeaderFooter(sect.Document, headerType)
End If

’ Insert a clone of the watermark into the header.
End Sub

Hi Steve,

Thanks for your inquiry. Please attach your input Word document (.doc file) here for testing? I will investigate the issue on my side and provide you more information.

Best regards,

Thx for the response. Attached is the document w/o the watermark

Hi Steve,

Thanks for your inquiry. I tested the scenario with Aspose.Words 13.4.0 and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-8254. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Steve,

It is to update you that our development team has completed the analysis of this issue; the problem occurs because when you use TiffCompression.Ccitt4 the document is converted to black and white so some data may be lost, it’s the expected behaviour. To remedy this problem, you can use any of the following workarounds:

  1. Change colour of watermark: In InsertWatermarkText method you can use Gray, Black or some other colour that is darker than Gray colour as follows.
watermark.Fill.Color = Color.Gray;
watermark.StrokeColor = Color.Gray;
// watermark.Fill.Color = Color.Black;
// watermark.StrokeColor = Color.Black;
// watermark.Fill.Color = Color.FromArgb(125, 125, 125);
// watermark.StrokeColor = Color.FromArgb(125, 125, 125);
  1. Make the whole image darker: Please insert the following statement before saving to Tiff.
options.ImageBrightness = 0.49f;
  1. Use another Tiff compression, e.g. Lzw:
options.TiffCompression = TiffCompression.Lzw;

Please let us know if above workarounds are acceptable for you?

Best regards,

Awais -

Thanks for the workarounds. Black works fine as does changing the compression to a non CCITT format. I will pass these workarounds to my colleagues and get their opinion, but I see no problems with any of them.



Hi Steve,

Thanks for your feedback. Our development team has completed the work on the issue (WORDSNET-8254) and has come to a conclusion that this issue and the undesired behaviour you’re observing is actually not a bug in Aspose.Words. So, we’ve closed this issue as ‘Not a Bug’. If we can help you with anything else, please feel free to ask.

Best regards,