I have Adobe X1 SDK. And I am trying to add a watermark to a pdf. There is an example in c# that comes with the SDK, here watermark is inserted on the top of the first page, I need to insert the watermark on mouse click, that is wherever i click the mouse i want this watermark to be inerted on the pdf document.
Here is the original Adobe sample code
private void addWatermarkButton_Click(object sender, EventArgs e)
{
String filter = "PDF Files (*.pdf)|*.PDF|" +
"All files (*.*)|*.*";
String filename = chooseFile(filter);
if (filename != null && g_AVDoc.IsValid())
{
CAcroPDDoc pdDoc = (CAcroPDDoc)g_AVDoc.GetPDDoc();
Object jsObj= pdDoc.GetJSObject();
object[] addFileWatermarkParam = { filename, 0, 0, 0, true, true, true, 0, 3, 10, -10, false, 0.4, false, 0, 0.7 };
Type T = jsObj.GetType();
T.InvokeMember(
"addWatermarkFromFile",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, jsObj, addFileWatermarkParam);
System.DateTime currentTime = System.DateTime.Now;
Object colorObj = T.InvokeMember(
"color",
BindingFlags.GetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, jsObj, null);
Type colorType = colorObj.GetType();
Object blueColorObj = colorType.InvokeMember(
"blue",
BindingFlags.GetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, colorObj, null);
object[] addTextWatermarkParam = { currentTime.ToShortTimeString(), 1, "Helvetica", 100, blueColorObj, 0, 0, true, true, true, 0, 3, 20, -45, false, 1.0, false, 0, 0.7 };
T.InvokeMember(
"addWatermarkFromText",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, jsObj, addTextWatermarkParam);
}
}