Free Support Forum - aspose.com

How to insert image as watermark?

Hi ,
I am using Aspose.words for java . I want to insert image as a watermark in a document.is it possible ?
And If document contains watermark with image ,is it possible to get watermark image properties like washout,scale ? I attached sample document with this post .

Do help me .

Regards,
Anbu Chezhian.S

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Yes of course you can insert image watermark in the document using Aspose.Words. Please follow the link to learn how to achieve this:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/add-a-watermark-to-a-document.html

Best regards,

HI ,
Thanks for your reply.
Is there any direct way to convert shape into Image ?. Because after identifying current shape as image ( watermark ),i need to save them directly either as file or as stream.is it possible?
At present i am using " doc.save " option to save all images. But i felt it is an costly process . What i need is to save Watermark image separately with unqiue name so that i can do watermark process .
Do help me .

NodeCollection shapesColl = doc.getChildNodes(NodeType.SHAPE, true, false);
{
Shape shape = (Shape)shapesColl.get(0);
if (shape.getName().contains(“Water”))
{
if(shape.isImage()){
// Image WaterMark
// doc.save(“Image.html”,SaveFormat.HTML);
}
else{
// Text WaterMark
}
}
}

Thanks

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. If your shape contains an image, you can try using the following code to extract this image:

// Open document.

Document doc = new Document(@"Test001\in.doc");

// Get Shape.

Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);

// Check if the shape contains an image.

if(shape.HasImage)

// Save image.

shape.ImageData.Save(string.Format(@"Test001\out.{0}", shape.ImageData.ImageType));

Hope this helps.

Best regards,