🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.sdk
Article #204

Re: Encrypt PDF Files - Adobe Acrobat SDK

#204
From: Galahad_Phillips
Date: Fri, 03 Apr 2009 15:11
42 lines
2132 bytes
Ok I'm making progress I think :)

The following code should encrypt the pdf file hopefully, however once I execute this code and then open the PDF file, it opens fine:

AFormApp formApp;
CAcroAVDoc doc;
Fields fields;
string nVersion;
string menuItem = string.Empty;
string certPwd = string.Empty;
string jsCode = string.Empty;

//open pdf
doc = (CAcroAVDoc)Interaction.CreateObject("AcroExch.AVDoc", "");
doc.Open(fileName, "Test PDF");

//acrobat form object
formApp = (AFormApp)Interaction.CreateObject("AFormAut.App", "");

//access some object property in objects inside AcroForm.
fields = (Fields)formApp.Fields;

certPwd = "test";
menuItem = "ADBESDK:AddSignature";
jsCode = "SetUserPassword(" + "'" + certPwd + "'); SetUserDigitalIDPath(" + "'" + certPath + "');" + "app.execMenuItem(" + "'" + menuItem + "');";

fields.ExecuteThisJavascript(jsCode);
doc.Close(0);

I created this code based on a sample from the SDK project called FillFormCS.

There's a section in there that contains the following comment:

/******************************************************
  VB code in an Acrobat IAC program
  to sign a PDF quietly ( no Acrobat running on screen ),
  using the JS methods in this file
* *****************************************************

When signing a PDF file is referred to, is in the context of encrypting it with a certificate? Or is it referring to a different kind of signature? Are there any changes I have to make to existing PDF's to encrypt them with a cert?

Thx again!
Technical Details
Message-ID: <59b879e2.6@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
References: <59b879e2.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10177e,296247912cdfb82
X-Google-Attributes: gid10177e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Galahad_Phillips@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.acrobat.sdk
Subject: Re: Encrypt PDF Files - Adobe Acrobat SDK
Message-ID: <59b879e2.6@webcrossing.la2eafNXanI>
Date: Fri, 3 Apr 2009 08:11:54 -0700
References: <59b879e2.-1@webcrossing.la2eafNXanI>
Lines: 49
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit