none
watermark RRS feed

  • Question

  • Is it possible to programmatic determine if the document has a watermark embedded ?

    Also can we disable watermark when printing ?

    Thursday, September 6, 2012 6:18 PM

Answers

  • Hi tootieroo

    You know, it would help us to help you if you could provide a complete problem description at the beginning. Your "and oh, by the way" mention that the watermark needs to be present after printing changes the entire scenario. That's very different than deleting!

    At this point, I recommend you SAVE the document before removing the watermark and printing, then close it after printing without saving changes (the deletion of the watermark), then re-open it.

    If you want to research it, the Shape object does have a Visible property that can be set to False, which would be an alternative.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by tootiereoo Monday, September 10, 2012 8:54 PM
    Monday, September 10, 2012 1:09 PM
    Moderator

All replies

  • Which version of Word is involved and in which file format is the document saved (*.docx or the old *.doc)?

    Would the document contain any other graphic objects that would be affected by a setting to suppress the printing of graphics?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 7, 2012 5:36 AM
    Moderator
  • Using Word 2010 and the file saved is *.docx.

    No the document does not contain any other graphic objects.

    We want the watermarks to be printed in Draft copies and remove watermarks during final printing.

    Friday, September 7, 2012 12:17 PM
  • Hi tootiereoo

    Thank you for the additional information.

    There are a number of possibilities

    1. You can suppress the watermark by deactivating the option File/Options/Display/Printing options/Print drawings created in Word. This will not, however, remove the watermark from the document. In the object model: Application.Options.PrintDrawingObjects = true/false

    2. You can delete the watermark; this is permanent, unlike (1). IF the watermark has been inserted using the PageLayout/Page Background/Watermark button then: Application.WordBasic.RemoveWatermark

    Note: If you're coding in C# then you need to use late binding (P-Invoke) to call WordBasic commands.

    If the watermark has been inserted otherwise, then you need to delete the Shape object from the Header/Footer area. How simple or complex this code has to be will depend on how many Section items the document has. In its simplest form:
    ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes(1).Delete

    3. The watermark can also be removed from the closed file by leveraging Office Open XML using the Open XML SDK


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 7, 2012 2:16 PM
    Moderator
  • Thanks Cindy, You solution works for me.

    But if there are any graphic objects, what would be the solution ? Do we need to check only for WaterMark shape type and Hide them ?

    Friday, September 7, 2012 6:43 PM
  • But if there are any graphic objects, what would be the solution ? Do we need to check only for WaterMark shape type and Hide them ?

    I'm not sure there's a "Watermark shape type". If the Watermark button is used to insert the Watermark, then it would have a Name something like:
    PowerPlusWaterMarkObject357870517

    But please note it's also possible to create a watermark the "old fashioned way", by using a Textbox and applying the proper formatting, step-by-step.

    As long as you can be sure it's a built-in Watermark, you can loop the Shapes, check the Name property and delete the specific Shape. Pseudocode:

    For each shp in ActiveDocument.Sections(1).Headers wdHeaderFooterPrimary).Shapes
      If Instr(shp.Name, "WaterMark") <> 0 Then
        shp.Delete
        Exit For
      End If
    Next


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, September 8, 2012 8:08 AM
    Moderator
  • Hi Cindy,

    I tried your Solution to Delete the Watermarks based on the name.

    While printing the Watermarks gets deleted properly and the final printout does  not have them.

    I want to restore them back to the document, So I will have to store the name and add them back ?

    On which event should I add them back, Are you aware of any event that will help me do that.

    Thanks,

    Monday, September 10, 2012 12:25 PM
  • Hi tootieroo

    You know, it would help us to help you if you could provide a complete problem description at the beginning. Your "and oh, by the way" mention that the watermark needs to be present after printing changes the entire scenario. That's very different than deleting!

    At this point, I recommend you SAVE the document before removing the watermark and printing, then close it after printing without saving changes (the deletion of the watermark), then re-open it.

    If you want to research it, the Shape object does have a Visible property that can be set to False, which would be an alternative.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by tootiereoo Monday, September 10, 2012 8:54 PM
    Monday, September 10, 2012 1:09 PM
    Moderator
  • Thanks Cindy for your help. Your pointers have helped me.

    Will be more specific hence forth on the problem description. Thanks for your time.

    I used the Shape object Visible property to hide the watermarks.

    Monday, September 10, 2012 8:56 PM