If...Then to terminate Applescript for Acrobat
If...Then to terminate Applescript for Acrobat
- Subject: If...Then to terminate Applescript for Acrobat
- From: Brendan Regan <email@hidden>
- Date: Thu, 4 Mar 2004 08:17:40 -0800 (PST)
Hello:
Sorry for multiple postings but I'm still stuck on
composing an AS (v. 1.5.5, OS 9.2) that will merge two
PDF's (Acr 5.0) of undefined but equal lengths so that
every odd page of the final document will be from one
source doc and the even pages will be from the other
source document. I can't figure out a way to terminate
the script once the two documents are merged, though.
Right now I have two working models. The first goes:
tell application "Acrobat 5.0"
count pages of document "100 pgs red.pdf"
set x to result
insert pages document "100 pgs red.pdf" after x from
document "100 pgs blue.pdf" starting with x number of
pages 1
insert pages document "100 pgs red.pdf" after (x - 1)
from document "100 pgs blue.pdf" starting with (x - 1)
number of pages 1
insert pages document "100 pgs red.pdf" after (x - 2)
from document "100 pgs blue.pdf" starting with (x - 2)
number of pages 1
insert pages document "100 pgs red.pdf" after (x - 3)
from document "100 pgs blue.pdf" starting with (x - 3)
number of pages 1
...
All the way down to page (x-60). The problem with the
script is that it goes on to add 60 pages even if the
two documents have only, say, 10 pages each.
So I added the following statement in between each
line:
if x = 1 then
"end tell"
end if
Of course, x = 2 on the second time around, and so on.
This didn't work at all and my computer nearly slapped
me for thinking I could terminate the script in the
middle of an if statement.
Then i came up with the second model, which i was sure
would work, even if it takes a while to compile:
tell application "Acrobat 5.0"
count pages of document "100 pgs red.pdf"
set x to result
insert pages document "100 pgs red.pdf" after x from
document "100 pgs blue.pdf" starting with x number of
pages 1
if x = 2 then
insert pages document "100 pgs red.pdf" after x from
document "100 pgs blue.pdf" starting with x number of
pages 1
insert pages document "100 pgs red.pdf" after (x -
1) from document "100 pgs blue.pdf" starting with (x -
1) number of pages 1
end if
if x = 3 then
insert pages document "100 pgs red.pdf" after x from
document "100 pgs blue.pdf" starting with x number of
pages 1
insert pages document "100 pgs red.pdf" after (x -
1) from document "100 pgs blue.pdf" starting with (x -
1) number of pages 1
insert pages document "100 pgs red.pdf" after (x -
2) from document "100 pgs blue.pdf" starting with (x -
2) number of pages 1
end if
So on and so on until if x=60...
This script returned curious results: it inserts page
x (the last page) at the end of the document x number
of times. The final document has the right number of
pages, but they're the wrong pages.
Any suggestions or corrections or wake up calls or
slaps upside the head would be greatly appreciated.
Thanks,
Brendan Regan
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.