Extract info from watermark

Is there a way to extract text info or image info from the watermark in a word document?

@Devanandan.Subbarayalu Aspose.Words provides Watermark class that allows creating and removing watermarks in MS Word documents. Watermarks in MS Word documents are represented with shapes in the document header (behind the main document content) with a special name ( contains "watermark" word) that allows identify them as watermarks. So to get watermark text or image, in case of image watermark, you should simply find such shape and extract the required content from it. For example the following simple code demonstrate the basic technique:

doc = aw.Document("C:\\Temp\\in.docx")

for node in doc.get_child_nodes(aw.NodeType.SHAPE, True) :
    s = node.as_shape()
    if ("watermark" in s.name.lower()) :
        if s.has_image :
            # Save watermark image to the file.
            s.image_data.save("C:\\Temp\\watermark." + aw.FileFormatUtil.image_type_to_extension(s.image_data.image_type))
        else :
            # Print watermark text
            print(s.text_path.text)
1 Like