re: Script to combine/concatenate PDF files?
re: Script to combine/concatenate PDF files?
- Subject: re: Script to combine/concatenate PDF files?
- From: Robert Kiolbassa <email@hidden>
- Date: Wed, 17 Oct 2001 13:46:59 -0500
On Wed, 17 Oct 2001 15:05:22 +0300 Tero Siili <email@hidden> wrote:
Subject: Script to combine/concatenate PDF files?
>
I and my colleagues are in need of a (batch) tool that would permit
>
one to combine a set of PDF files to a single file - either to create
>
a new one or append the other PDF files to the first one. I have
>
considered doing this by means of scripting the Acrobat 4.0
>
application. At first glance to the apps dictionary this seems not to
>
be a trivial task - some of the information required by the insert
>
command seems not to be self-evidently available.
Tero,
This is from a large kernel of code posted to this AS digest some time ago.
Unfortunately I have long since lost any note who from this list contributed
the code. Drop the pdfs onto the icon and it will merge all pdfs into one by
using the apha order of the files (as viewed in the Finder) you drop on it.
This Script requires Acrobat 4.0 to work. Make sure neither Distiller or
Reader is open when this is run. Not tested on Acro5.
Hope this helps.
-- -start script ----watch those line breaks. Save as an app, should be a
droplet
on open fileList
set theCount to (count each item of fileList)
set newFile to choose file name with prompt "Name your new PDF file?:"
default name "Files" & theCount & ".pdf"
tell application "Acrobat(tm) 4.0"
activate
end tell
tell application "Finder"
set fileList to (sort fileList by name) as alias list
set doc1 to name of item 1 of fileList
end tell
tell application "Acrobat(tm) 4.0"
open (item 1 of fileList) with invisible
set fileList to rest of fileList
repeat with afile in fileList
tell application "Finder"
set doc2 to name of afile
end tell
set pageCount to count each PDPage of document doc1
open afile with invisible
set pageCount2 to count each PDPage of document doc2
insert pages document doc1 from document doc2 starting with
1 number of pages pageCount2 after pageCount
close document doc2 saving no
end repeat
activate
save document doc1 to newFile with linearize
display dialog "Finished."
end tell
activate me
end open
-- end script
Bob Kiolbassa