hi,
I am using Acrobat 7.0.
Using C# and Interop.Acrobat.dll I am accessing JSObject of the pdf and trying to add a stamp to the pdf which is not working fine. I, however, successfully managed with inserting watermarks.
It always adds the default "draft" stamp but I cannot modify it using javascript and "AP" property of the annotation object.
Following is my code snippet,
public static int Stamp(string fileToMark, string outputFile, string author, string contents, string subject, Color color)
{
................
............
.....
for (int i = 0; i < oNumPages; i++)
{
annotObj = T.InvokeMember(
"AddAnnot",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, jsObj, null);
Type annotType = annotObj.GetType();
propsObj = annotType.InvokeMember(
"getProps",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, annotObj, null);
Type propsType = propsObj.GetType();
//start setting properties.
//type property
object[] typeParam = { "Stamp" };
propsType.InvokeMember(
"Type",
BindingFlags.SetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, propsObj, typeParam);
//page number property
object[] pageParam = { i };
propsType.InvokeMember(
"page",
BindingFlags.SetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, propsObj, pageParam);
.........................
..............
//annotation name property
object[] nameParam = { "PWAnno" };
propsType.InvokeMember(
"name",
BindingFlags.SetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, propsObj, nameParam);
object[] setPropsParam = { propsObj };
annotType.InvokeMember(
"setProps",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, annotObj, setPropsParam);
/////////////////////////////////////////////
//object[] getAnnotParam = { i, "PWAnno" };
//annotObj = T.InvokeMember(
// "getAnnot",
// BindingFlags.InvokeMethod |
// BindingFlags.Public |
// BindingFlags.Instance,
// null, jsObj, getAnnotParam);
//annotType = annotObj.GetType();
//now that stamp is already created and added to document, getProps needs to be revoked so that this time we can get reference of "AP" property
propsObj = annotType.InvokeMember(
"getProps",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, annotObj, null);
propsType = propsObj.GetType();
//annotation appearance property
object[] APParam = { "confidential" };
propsType.InvokeMember(
"AP",
BindingFlags.SetProperty |
BindingFlags.Public |
BindingFlags.Instance,
null, propsObj, APParam);
object[] setPropsParam2 = { propsObj };
annotType.InvokeMember(
"setProps",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, annotObj, setPropsParam2);
}
........
........
return 0;
}
As you can see I tried to modify the "AP" property to "Confidential" but it always puts "draft" stamp in it which is the default.
Kindly help me.
Regards,
Nikhil.
The AP property has to be set to the actual Stamp name. There are three confidential stamps. On the Standard Business list the name is "SBConfidential", There's also one named just "Confidential", and the one on the Dynamic stamps named "#DConfidential".
All of these work for me.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script