Copy link to clipboard
Copied
I have been trying to insert a stamp using the AddAnnot method and this is the code I have:
Function Doug(FileName, path) As Long
Dim Acroapp As Acrobat.Acroapp
Dim Doc1 As Acrobat.AcroPDDoc
Dim CodeBox As Acrobat.AcroPDAnnot
Dim Page As Acrobat.AcroPDPage
Dim Cod1 As Acrobat.AcroPDDoc
Dim gap As Acrobat.AcroPDPage
Dim annot As Object
Dim prop As Object
Dim jso As Object
Dim arr(0 To 3) As Integer
Set Acroapp = CreateObject("AcroExch.App")
Set Doc1 = CreateObject("AcroExch.PDDoc")
'Set Cod1 = CreateObject("AcroExch.PDDoc")
arr(0) = 0
arr(1) = 0
arr(2) = 300
arr(3) = 300
If Doc1.Open(path & FileName) = True Then
Set Page = Doc1.AcquirePage(0)
Set jso = Doc1.GetJSObject
If Not jso Is Nothing Then
Set annot = jso.AddAnnot()
Set prop = annot.GetProps
prop.Type = "Stamp"
annot.setprops prop
Set prop = annot.GetProps
prop.AP = "#kZBRdNJ8NdlGCzWSCKIn3A"
prop.rect = arr
annot.setprops prop
End If
Doc1.Save 1, path
Doc1.Close
End If
End Function
It adds an annotation, but its just a box with no text in it. What am I doing wrong?
Copy link to clipboard
Copied
This code creates an empty annotation. You must also the text.
Copy link to clipboard
Copied
This code is supposed to create a stamp, that has a text. Therefore it needs to pass the AP property of the Stamp type annotation into the javascript code. I think that that's where the problem is - the AP property is not getting passed through.
Copy link to clipboard
Copied
What documentation leads you to conclude that (a) you need to pass AP (b) you pass a value of this form. I've never done it but it doesn't look quite right. Please let us know what you are following.
Copy link to clipboard
Copied
If i write a javascript code with the line this.addAnnot({page:0,type:"Stamp",rect:[100,100,350,350],AP:"#kZBRdNJ8NdlGCzWSCKIn3A"})
it does exactly what I need, because I do pass the AP to the AddAnnot method. SDK documentation agrees with me on it:
JavaScript > JavaScript for Acrobat API Reference > JavaScript API > Annotation > Annotation properties > AP
I want to know how to do the same line of code as above, only using VBA (I cannot use folder-level scripts in my environment).
Copy link to clipboard
Copied
I would try using that JavaScript you posted using the Fields.ExecuteThisJavascript method instead of trying to use the JSO method. I've always had better luck with it.
Copy link to clipboard
Copied
Hello. You forgot to add to what page you want to put stamp. The code should be:
Set prop = annot.GetProps
prop.Page = 0
prop.AP = "#kZBRdNJ8NdlGCzWSCKIn3A"
prop.rect = arr
annot.setprops prop
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more