Need javascript/VB code to open passwordprotected PDF file by passing password in codeitself.

Ask a Question related to Adobe Acrobat SDK, Design and Development.

  1. #1

    Default Need javascript/VB code to open passwordprotected PDF file by passing password in codeitself.

    Hi,

    I have used PDFcreator to create the PDF file with password security

    'To create PDF file with password security
    With PDFCreator1



    ..cOption("UseAutosave") = 1
    .cOption("UseAutosaveDirectory") = 1
    ' ==============
    .cOption("AutosaveDirectory") = strBackupPath '& "\" & Format(Trim(Sheets("Form16_Database").Range("A" &

    I).Value), "0#####") & "\" 'ActiveWorkbook.Path
    Debug.Print Trim(Sheets("Form16_Database").Range("A" & I).Value) & "Form16-" & Format(Trim(Sheets

    ("Form16_Database").Range("A" & I).Value), "0#####") & "-" & Format(Now(), "YYYYMMDDHHMMSS") & ".PDF"
    .cOption("AutosaveFilename") = Format(Trim(Sheets("Form16_Database").Range("B" & I).Value), "0#####") & ".PDF"
    FileName = Format(Trim(Sheets("Form16_Database").Range("B" & I).Value), "0#####") & ".PDF"
    .cOption("AutosaveFormat") = 0
    .cOptions.PDFUseSecurity = 1
    .cOption("PDFOwnerPass") = 1
    .cOption("PDFOwnerPasswordString") = "mypass"
    .cOption("PDFUserPass") = 1
    .cOption("PDFUserPasswordString") = "mypass"

    ..cClearCache

    End With
    'Printing to PDF Creator
    ActiveSheet.PrintOut Copies:=1, ActivePrinter:="PDFCreator"

    'Making the system wait for the PDF creator to create the file
    Do Until PDFCreator1.cCountOfPrintjobs = 1
    DoEvents
    Sleep 1000
    Loop

    PDFCreator1.cPrinterStop = False
    Sleep 1000

    ''and To fix digital signature used below code from Acrobat SDK 8.1..

    ''VB code for fixing Digital Signature --calling jaascript file from SDK.

    Sub GetDigitalSignature(PDFFilepath As String, PDFFileName As String, PFXfile As String, Password As String, Top As Double,

    Left As Integer)

    Dim gapp As Acrobat.AcroApp
    Dim gpddoc As Acrobat.AcroPDDoc

    Dim jso As Object
    Dim FullPath As String
    Dim avDoc As CAcroAVDoc
    Dim boK As Boolean
    Dim ppklite As Object
    Set avDoc = CreateObject("AcroExch.AVDoc")
    Set gapp = CreateObject("acroexch.app")
    Set gpddoc = CreateObject("acroexch.pddoc")
    boK = avDoc.Open(PDFFilepath, PDFFileName)
    gpddoc.Open (PDFFilepath)

    Set jso = gpddoc.GetJSObject()
    jso.SetUserPassword (Password)
    jso.SetUserDigitalIDPath (PFXfile)
    jso.SetSignTop (Top)
    jso.SetSignLeft (Left)
    jso.app.execMenuItem ("ADBESDK:AddSignature")
    avDoc.Close (True)
    gapp.Exit

    End Sub

    Now i am able to create PDF with Digital signature. But We want to assign password protection too..and problem is once we fix Digital signature we can't change security.

    My problem is to pass password at the time of opening PDF for embedding signature. Password window should not prompt to the user while running VBA application.

    Can you please help me to pass password on fly when file prompt password while opening PDF file. As file need to be opened at the time of fixing signature using sdk javascript code.
    meghadwivedi@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. OpenInWindowEx method fails to open password protected pdf file
      Hi, I am getting error while loading the password protected pdf file using OpenInWindowEx method. Any Idea why or any fix of problem? Regards,...
    2. VB.net Open a pdf file with password!
      Allo, I know how to open a file. Pdf who is with a password in vb.net thx
    3. Reader plug-in, save copy of passwordprotected pdf without password
      Hello, We currently have an Acrobat Reader plugin (using the 8.1 SDK) and are having trouble with password protected PDFs. The sole purpose of...
    4. Passing code/data from code-behind to ASPX page
      I have the following code in my code-behind file: DataGrid MAPPsDataGrid = (DataGrid)((((((Repeater) sender).Parent).Parent).Parent).Parent); ...
    5. Open file, make changes, save file, close, re-open, file contents not changed
      I've now run into this several times and it's completely destroyed all of my confidence in Ilustrator CS on Mac. I'm hoping someone can confirm that...
  3. #2

    Default Re: Need javascript/VB code to open passwordprotected PDF file by passing password in codeitself.

    Correct, you need to encrypt then sign.

    Unfortunately, there is no way to pass a password for opening.
    Leonard_Rosenthol@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139