Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Combining a group of file into a single PDF (automation) (Acrobat 9)

Combining a group of file into a single PDF (automation) (Acrobat 9)

Combining a group of file into a single PDF (automation) (Acrobat 9)

Long story short, I'm kicking off most of this code from VBA in Excel, but I'll get to that later. First: I'm having trouble with running the javascript, and it seems like it's a fairly simple syntax issue, but only time shall tell.

The process goes something along the lines of this:

    Create new pdf document
    Open/convert each file and insert pages from the file into new document
    Close converted files
    Save combined PDF

I can create a new document, no sweat, but when I call the code to open and convert a file, I run into problems. Here:


    Set jDoc = jApp.openDoc("C:\Users\xxxx\Documents\test.txt", "True")
I quickly learned that there were two things wrong with this: one that my Acrobat security settings did not like that, and that my syntax was wrong.

I started fixing the Security problem by reading through the Acrobat 9 JavaScript API. Well, turning on the setting to allow menu item execution wasn't the answer, so I added this to my Javascripts folder in my Adobe install folder:


    function tOpenDoc(fPath, bConv)
    app.openDoc({ cPath: fPath, bUseConv: bConv });


And to test I added this at the end:


    tOpenDoc({ cPath:"C:\Users\xxxx\Documents\test.txt", bUseConv: true });

Where the console pops up and tells me

NotAllowedError: Security settings prevent access to this property or method.

(If I call the function from my VBA code it just tells me the server threw an exception, which is marvelously helpful.)

anyhow, here's my entire VBA code if you care about that at all:


Sub test()

Dim app As AcroApp
Dim aDoc As AcroAVDoc
Dim pDoc As AcroPDDoc
Dim jso As Object
Dim jApp As Object
Dim jDoc As Object

Set app = CreateObject("AcroExch.App")

Set pDoc = CreateObject("AcroExch.PDDoc")
Set jso = pDoc.GetJSObject
Set jApp = jso.app

Set jDoc = jApp.tOpenDoc("{ cPath:""C:\Users\xxxx\Documents\test.txt"", bUseConv: true }")
    If pDoc.InsertPages(pDoc.GetNumPages - 1, jDoc, 0, jDoc.GetNumPages(), True) = False Then
        MsgBox "Nuh-uh Nancy"
    End If

End Sub

It obviously doesn't get past the tOpenDoc() call.

RE: Combining a group of file into a single PDF (automation) (Acrobat 9)

Update: the Acrobat 9 Javascript API says:

    Note: (Acrobat 7.0) bUseConv can only be set to true during a console or batch event. See also Privileged versus non-privileged context.

Is this my issue? Researching Batch Sequences now to see if I can make that work, in the meantime I'll be checking back here.

RE: Combining a group of file into a single PDF (automation) (Acrobat 9)

General update:
I don't see a way to kick off a batch sequence through the JavaScript or through VBA. I assume that was the point of making some things only available during a batch event.
I'll research a couple other options but it's appearing like this isn't possible with my current limitations; however, I don't believe it is altogether impossible. If anyone has ideas, I'd love to hear them!

RE: Combining a group of file into a single PDF (automation) (Acrobat 9)

Solved my problem. Instead of using any javascript or settings from Acrobat, I instead used the default data models of VBA to convert all of the files I hope to see to either a powerpoint, word doc, or excel file. From that point I save them as PDF, and after that combine all the files. With VBA.

If anyone is interested in doing this outside of VBA and need a solution that does not require office to be installed, there was a glimmer of hope in locating the dll that makes the shell execute call. I found the DLL, and the call that it makes. The message is unfortunately encrypted though, and I really did not feel like decrypting it and figuring out how to add a list of files into that message.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close