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

Digitallly sign & encrypt attachment

New Here ,
Apr 24, 2018 Apr 24, 2018

Copy link to clipboard

Copied

i want to design a pdf form with functionality to attach files and further encrypt/digitally sign it. i want to do it programmatically through javascripts or adobe APIs. i know there are 'security' and 'securityHandler' objects in this regard. kindly help that what i need to do it? Acrobat DC pro is enough or i will have to buy the adobe library also for this task. And what is the role of Acrobat SDK in this??

TOPICS
Acrobat SDK and JavaScript , Windows

Views

300

Translate

Translate

Report

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

LATEST

Hi sanakk,

I have a folder-level script that I use for my company that gives users a "Certify" Button. It invisibly signs the document using their pfx file. I have VBScript installer that the user runs to install the .js file to the path with their pfx filepath and password.

Filepath example: C:/Users/ME/AppData/Roaming/Adobe/Acrobat/2015/Security/CERTIFICATE.pfx

Folder-Level Script Path Example: C:\Users\ME\AppData\Roaming\Adobe\Acrobat\Privileged\DC\JavaScripts

(2015 for 2015 version, DC for latest version)

This script adds a custom tool with an icon to Acrobat upon launch. When activated, the user selects a save directory (cannot include the '!' character), and the document is flattened (prevents fillable fields from being edited by customers in other PDF readers, like Chrome), and then invisibly signed with a company signature.

If you don't want this tool to load in the webpage viewer, you'll need a call to another script that checks if the document is open externally.

This will work with Acrobat Standard DC or Pro.

var AutoCertify = app.trustedFunction(function() {

     app.beginPriv();

     var myEngine = security.getHandler( "Adobe.PPKLite" );

     myEngine.login( "PASSWORD HERE", "PFX PATH HERE" );

     var myInfo = {password: "PASSWORD HERE", reason: "JavaScript", mdp: "allowNone"};

     var oRtn = app.browseForDoc(true);

     if (oRtn !== undefined){

          var strFinalPath = oRtn.cPath;

          var exp = /!/;

          if (exp.test(strFinalPath)){

               app.alert("File path contains illegal character: '!' - Cannot Certify to this directory.");

          }

          else{

               this.flattenPages();

               this.certifyInvisibleSign({oSig: myEngine, oInfo: myInfo, cDIPath: strFinalPath});

          }

     }

     app.endPriv();

});

var AddCertify = app.trustedFunction(function() {

     app.beginPriv();

     var strHex = "ff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14dff23b14d";

     var oIcon =

     {

          count: 0,

          width: 12,

          height 16,

          read function(nBytes)

          {

               return strHex.slice(this.count, this.count += nBytes);

          },

          GetIcon: function(){

               this.count = 0;

               return this;

          }

     };

     app.addToolButton({

          sName: "Certify",

          oIcon: oIcon,

          cExec: "AutoCertify();",

          cTooltext: "Certify",

          cEnable: true,

          nPos: 0,

          cLabel: "Certify",

          cMarked: false

     });

     app.endPriv();

});

AddCertify();

As far as encryption to the PDF or the attached files I have no idea. Based on what I know with data objects within the JavaScript API, there are many security restrictions to do much programmatically, so I do not believe it's natively possible. You would probably need to encrypt the whole pdf file using some other tool or language..

Hope this somewhat answers your question; it took me a little while to figure this one out ages ago.

Votes

Translate

Translate

Report

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