I have added a watermark to my pdf using the following code. My actual requirement is to display the watermark when the user tries to print the pdf. (print preview and the printed copy should have the watermark and not
on the original doc on the viewer)
I set the flags ShowsOnScreen(false) and ShowsOnPrint(true) but it displays on the print preview but also display on the viewer as well.
Another issue is this watermark can be selected and do other annotations like highlighting.
Please suggest me a workaround. Either I need to hide the watermark from the viewer and display only on print preview/print
or
Show me a way that watermark displays on the viewer as well but it has to be read-only.
using (Stamper st = new Stamper(StamperSizeType.e_relative_scale, 0.9, 0.9))
{
pdfDoc.InitSecurityHandler();
st.SetAlignment(StamperHorizontalAlignment.e_horizontal_center, StamperVerticalAlignment.e_vertical_center);
st.SetFontColor(new ColorPt(0, 0, 0)); st.SetOpacity(0.3);
st.SetAsBackground(false);
st.ShowsOnScreen(false);
st.SetRotation(-45);
st.ShowsOnPrint(true);
st.SetAsAnnotation(false);
st.StampText(pdfDoc, "If you are reading this\nthis is an even page", new PageSet(1, pdfDoc.GetPageCount()));
}