Skip to main content
Known Participant
July 2, 2019
Answered

How to check if a PDF Page has no annotations like comments or Fill and Sign

  • July 2, 2019
  • 3 replies
  • 8189 views

Hello,

is it possible to check if a PDF page has no annotations like comments of Fill and Sign. I'm working with Adobe Acrobat and VBA.

I need a function with result =  false if there is no Comment or Fill and Sign on a page of a PDF document. I hope someone can help me with a little bit code.

Best Regards from Germany

Josua

This topic has been closed for replies.
Correct answer Bernd Alheit

You can use the VB Javascript bridge. Documentation is in the Acrobat SDK.

3 replies

Legend
July 9, 2019

You don’t need to make and call a function. You can’t define functions through JSObject so far as I know.

Known Participant
July 4, 2019

Hello Bernd,

thanks for your answer. How can I implement it in VBA?

Best Regards

Josua

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
July 4, 2019

You can use the VB Javascript bridge. Documentation is in the Acrobat SDK.

try67
Community Expert
Community Expert
July 7, 2019

Now I have a file  CheckAnnots.js with the following code in C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts

function CheckAnnots(doc, nPage)

doc.syncAnnotScan();  

var annots = doc.getAnnots({nPage: nPage});  

if (annots==null || annots.length==0) return false; 

else return true; 

app.addMenuItem({cName: "check", cParent: "File", cExec: "CheckAnnots()"});

I hope this is correct?

My VBA Code is

Sub CheckPDFAnnotations()

Dim App As Acrobat.CAcroApp
Dim PDDoc As Acrobat.CAcroPDDoc
Dim i As Long
Dim jso As Object

Dim blnAnnotations As Boolean

Set App = CreateObject("AcroExch.App")
Set PDDoc = CreateObject("AcroExch.PDDoc")
PDDoc.Open ("C:\Users\Josua\Documents\Test01.pdf")

Set jso = PDDoc.GetJSObject

blnAnnotations = CheckAnnots(this, 0)

End Sub

But something must be wrong with Syntax   CheckAnnots(this,0)   ?

I think this is not correct or I Need   jso.CheckAnnots, too?


I can't help you with the VBA code, I'm afraid, but my guess is that the "this" keyword is the issue.

In JS it refers to the document, but probably not in VBA. I think you should replace it with the reference to your document (possibly PDDoc). You probably should also refer the jso object when calling the CheckAnnots function, yes. But again, I can't help with the exact syntax.

Bernd Alheit
Community Expert
Community Expert
July 4, 2019

With Acrobat Javascript you can test/check the annotations.