Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Combine 2 PDF files into 1 using applescript

Hi all,


I am just starting out with applescript and could do with a pointer please. I have written a script which saves two pdf files from an active Illustrator document in the source folder of that document. The issue I am have now is that I cannot get the two files to combine into a single PDF file.


The whole script is quite long and is works apart from the combine PDF part, I will paste the part of the code I am having problems with and hopefully someone can help me out please:


------------------- start of PDF combine script


tell application "Finder"

try

open (every document file of container of file_path whose name contains ".pdf")

on error

display dialog "no PDF file located"

end try

end tell

tell application "Adobe Acrobat Pro" to activate

tell application "Adobe Acrobat Pro"

set docRefA to the active doc

tell application "Finder"

try

open (every document file of container of container of file_path whose name contains ".pdf")

on error

display dialog "no PDF file located"

end try

end tell

tell application "Adobe Acrobat Pro" to activate

tell application "Adobe Acrobat Pro"

set docRefb to the active doc

bring to front docRefA

insert pages docRefA after 1 from docRefb starting with 1

end tell

end tell

------------------------------------- script end


Both PDF documents open and are set as the variables docRefA and docRefb, but the acrobat command 'bring to front' and 'insert page' do not seem to be working. I get an error come up in an illustrator dialog box saying "Adobe Acrobat Pro got an error: document "84056_R1.pdf" doesn't understand the bring to front message".

Mac OS X (10.6.8)

Posted on Jun 22, 2012 6:26 AM

Reply
26 replies

Jun 22, 2012 8:15 AM in response to Frank Caggiano

Thank you for the reply,


Here is a bit of background on the script and its use:

The script is currently used to produce PDFs in a production environment. Once artwork is complete the user clicks the script and it makes the pdfs and saves them in the correct place to the correct standard. Currently the user then has to combine the PDFs manually, I want to add this process to the current script as a continuation.

They could use automator but it would actually take longer than dragging and dropping one pdf file into the pages section in acrobat pro, which is what currently happens, so automator wouldnt really help.


The whole point of the script is to make pdfs, then save them, then combine them in one process.


I would really like help with the last part of the applescript please

Jun 22, 2012 8:50 AM in response to big_murph

in part your script was fubbed and in part Adobe's scripting design is fubbed. the following script does what you want when you run it, but won't compile in the applescript editor (certain properties and commands, like 'active doc' and 'bring to front' aren't recognized).


set file_path to alias "TMac:Users:tedwrigley:Test area:bibble:"


tell application "Finder"

set theFiles to (every file of file_path whose name extension is "pdf") as alias list

end tell


tell application "Adobe Acrobat Pro"


activate


opentheFiles


set docRefA to document 1

set docRefb to document 2


bring to frontdocRefA


insert pagesdocRefAafter 1 fromdocRefbstarting with 1 number of pages (count of pages of docRefb)

end tell

Jun 22, 2012 11:07 AM in response to twtwtw

My script runs and compiles completely fine. It is just when it hits the adobe acrobat commands that it doesn't work, which is why I am here to see if anyone knows a solution. You posted a different version of a script that does exactly the same thing as mine in a different way and fails at exactly the same point. Thanks for trying though.

Jun 22, 2012 11:26 AM in response to big_murph

The script works perfectly fine on my machine, with no errors. If you're getting errors, something's off on your end, not mine. Now I'm happy to help you work through the problem (look over my other contributions if you think I'm not qualified to do that), but that requires a fair amount of cooperation on your end. Yes, it's possible that someone else will answer your question on their first try, but that's not the way it usually works. Usually we have to go through a series of exchanges to narrow down the problem.


Unfortunately you've been rude to me twice - "thanks for trying" my proverbial [...] - and that's annoyed me. So if you want my help you you're going to have to ask for it explicitly. If you choose not to, then good luck, and I hope someone else can deliver you a magic bullet.

Jun 22, 2012 6:37 PM in response to big_murph

Yeah, but when you say "thanks for trying, can anyone else help please" it comes off a little rude, like ya that didnt work so is there anyone else I can bum an answer off of?


twtwtw took time out of his day to try to help you, in which he gets nothing in return but because it didnt work exactly as you wish you basically just kick him to the curb and on to the next guy (hopefully in your case) cause I dont think your getting anymore help from twtwtw

Jun 22, 2012 11:39 PM in response to BRAVOdirt

Oh, I don't take it personally. I'm mostly annoyed because he's making the process difficult; If he still wants help I'm happy to give it. But I can't read his mind and I can't see his computer, and I'm not all that inclined to keep guessing at solutions, so...


if he wants this solved he's going to have to come halfway into the conversation and work it through. Or he can mail me his computer and I'll charge him $500 to get it working just the way he wants. Whichever is good with me. This isn't magic, but some people insist on treating it like it is and it's not really my place to disillusion them. 😉

Jun 23, 2012 9:58 AM in response to big_murph

Fair enough. so let's check a couple of things.


  1. Which version of Acrobat Pro are you using?
  2. Do you have any third-party scripting additions installed?
  3. Since this block of code appears to be part of a larger script, is it embedded in another tell block, or a script handler, or maybe a script object? What (in general) happens before you reach this part of the code?


I may have to shift over to my 10.6 partition later to test it there in case it's an OS issue (that's unlikely, but possible), but let's start with this.

Combine 2 PDF files into 1 using applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.