/************************************************************************
*
* Function Name : setWatermarkPdf()
* Description : This function changes the Watermark of the pdf document
* according to the value of the Watermark of PrintParams Object
*
*************************************************************************/
static com.aspose.pdf.Document setWatermarkPdf(com.aspose.pdf.Document pdf1, String watermark)
{
if (!watermark.equals(""))
{
com.aspose.pdf.TextStamp textStamp = new com.aspose.pdf.TextStamp(watermark);
// Giving the look of a watermark
textStamp = WatermarkShapeSet(textStamp);
// Adding the textStamp on all the pages of the pdf document
for (int Page_counter = 1 ; Page_counter <= pdf1.getPages().size() ; Page_counter++)
{
pdf1.getPages().get_Item(Page_counter).addStamp(textStamp);
}
}
return pdf1;
}
/************************************************************************
*
* Function Name : WatermarkShapeSet()
Description : It changes the watermark related shaped accordingly to give
* it the required look of a watermark
*
*************************************************************************/
private static TextStamp WatermarkShapeSet(TextStamp textStamp)
{
// PdfWatermarkValues object is required to access needed constant values for constructing watermark
PdfWatermarkValues PWV = new PdfWatermarkValues();
textStamp.setBackground(true);
textStamp.setXIndent(PWV.textStampXIndent);
textStamp.setYIndent(PWV.textStampYIndent );
textStamp.setRotate(com.aspose.pdf.Rotation.on90);
new com.aspose.pdf.FontRepository();
textStamp.getTextState().setFont(FontRepository.findFont(PWV.textStampFont));
textStamp.getTextState().setFontSize(PWV.textStampFontSize);
textStamp.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Bold);
textStamp.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Italic);
textStamp.getTextState().setForegroundColor(com.aspose.pdf.Color.getGray());
return textStamp;
}
and its giving the results attached.. the original pdf and after watermark pdf with watermark text as "Hello Dude" is attached.
Please can you help to make it look bette rlike a proper watermark, transparent grey in color placed in the middle.
Thanks