Skip to main content
Participant
October 28, 2021
Question

How to check the security of a pdf-file through vb.net?

  • October 28, 2021
  • 1 reply
  • 870 views

Hello dear Adobe Support Community,

at the moment I'm working on a VB.NET project where I can merge several pdf-files to one pdf-file.

I'm using the Acrobat Library to accomplish this.

Now I have a problem with pdf-files which have security protections like read-only for example. Of course, this files can't be merged with the other files.

The idea is to have a For-Loop which checks every single pdf-file and returns an error message if the file is read-only.

My code looks something like this:

Dim appAcrobat As Acrobat.AcroApp
Dim apddSummary As Acrobat.AcroPDDoc   ' This contains all single pdf-files in the end.'
Dim apddSingle As Acrobat.AcroPDDoc    ' This contains a single pdf-file.'
Dim iNumPages As Integer
Dim iNumPagesSub As Integer

' At this point he should check the files. '

apddSummary.Open(Cstr(Me.ListBox1.Items(0)))
For Each strFound as String in Me.ListBox1.Items
If Me.ListBox1.Items.IndexOf(strFound) > 0 Then
iNumPages = apddSummary.GetNumPages()
apddSingle.Open(strFound)
iNumPagesSub = apddSingle.GetNumPages()
apddSummary.InsertPages(iNumPages -1, apddSingle, 0, iNumPagesSub, CInt(True))
apddSingle.Close()

' Where it gets saved, etc...'

In the For-Loop I go through a ListBox where I previously inserted all the pdf-files I want to merge. But before the program starts to merge I want to check if all pdf-files which are inserted are not read-only and throw them out if they actually are read-only.

 

Is there any command or something I can work with in VB.NET?

Thanks for your help!

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
November 1, 2021

there are no commands in the IAC related to document security. Howerver, IAC can communicate to the Acrobat JavaScript model through a JavaScript Object, and the JS Model has properties and functions for accessing document security.

 

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%2FIAC_DevApp_OLE_Support%2FUsing_the_JSObject_interface.htm

 

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2Fsecurity_constants.htm

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often