Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to use AP property of the stamp type annotation in javascript

New Here ,
Jul 25, 2016 Jul 25, 2016

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?

TOPICS
Acrobat SDK and JavaScript , Windows
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2016 Jul 25, 2016

This code creates an empty annotation. You must also the text.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2016 Jul 25, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 25, 2016 Jul 25, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2016 Jul 25, 2016

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 25, 2016 Jul 25, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2016 Sep 17, 2016
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines