RAT20V
07-07-2010, 04:59 AM
Hi All,
I have a Applescript that is inserted into the Script panel in indesign Cs2 and CS3,
This script, exports a pdf to PDFX1a and also a Digital Magazine Spec, thus creating 2 pdfs. It also puts a slug at the top left of the page outside the bleed area that includes the code and page number and a 5 digit random number.
This works fine on all the indesign files i create but i have a few random files sent to me and get so many problems, the script does not error but on some indesigns it put the page information in the middle of the page and also will not always is the font or font size i have asked it to use.
And on one occasion it has actually changed the running order of the text on the page and the runaround properties which is really odd.
The postion problem is because some of the indd docs i have had supplied the rulers are not set to zero top left corner.
Here is the script:
set pagerange to ""
set pagefrom to ""
set pageto to ""
set x to ""
tell application "Finder"
display dialog "Enter your page range:" default answer pagerange buttons {"OK"} default button 1
set pagerange to text returned of the result
set AppleScript's text item delimiters to {"-"}
set pagefrom to first text item of pagerange
set pageto to second text item of pagerange
end tell
tell application "Adobe InDesign CS3"
activate
set myPageNumPref to page numbering of general preferences
set page numbering of general preferences to absolute
set myPDF_prefs to PDF export preferences
tell myPDF_prefs
set page range to pagerange
set x to number of pages of page range
end tell
set theDocument to active document
set AppleScript's text item delimiters to {".indd"}
set myFileName to name of theDocument
set PageCount to number of pages of theDocument
set nameWithoutExtension to first text item of myFileName
if (count documents) is equal to 0 then
display dialog "Please open a document" buttons " OK " default button 1 with icon caution
return -128
end if
set myFolder to (choose folder with prompt "Please select the folder you want to save your PDF pages in") as string
set a to pagefrom as integer
set b to pageto as integer
set x to (b - a) + 1
set myPageNumber to (name of page a of theDocument)
-- need to initialize the array outsie of the repeat loop
tell theDocument
with timeout of 5000 seconds
repeat with x from a to b
set mynumbertest to (name of page a of theDocument) as integer
if mynumbertest is less than 10 then
set myPageNumber to "00" & (name of page a of theDocument)
else if mynumbertest is less than 100 then
set myPageNumber to "0" & (name of page a of theDocument)
else
set myPageNumber to (name of page a of theDocument)
end if
tell application "Finder"
set duplicates to {}
-- get a random number of up to 5 digits
set an_item to random number from 0 to 99999
-- this line zero-pads the random number
set an_item to text -5 thru -1 of ("00000" & an_item) as text
if an_item is not in duplicates then
set end of duplicates to an_item
end if
end tell
tell application "Adobe InDesign CS3"
activate
-- retain pointer to the opened document for later use
set theDocument to active document
--set delimiter to extension
set AppleScript's text item delimiters to ".indd"
--get the file name from ID since we are here anyway
set myFileName to name of theDocument
--Since the delimiter is the extension the first text item will remove the extension if it is part of the name
set myFileName to first text item of myFileName
--reset the delimiter to avoid potential problems
set AppleScript's text item delimiters to {".indd"}
-- add a basic text block with the filename & generated random number
tell page a of theDocument
if a mod 2 = 0 then
make new text frame with properties {contents:nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf", geometric bounds:{1, 211, -7, 301}}
else if a mod 2 is not equal to 0 then
make new text frame with properties {contents:nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf", geometric bounds:{1, 1, -7, 90}}
end if
tell parent story of text frame 1 of page a of theDocument
set applied font to "Arial"
set point size of word 1 to 8
end tell
end tell
--add the path, name and underscore together. ID ads the second underscore and page number automatically if there are more than one page to the document.
set thePath to (myFolder & nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf")
tell application "Adobe InDesign CS3"
set page range of PDF export preferences to (a as string)
export document 1 format PDF type to thePath using PDF export preset "WNMEDIA" without showing options
set thePath to (myFolder & nameWithoutExtension & "_" & myPageNumber & ".pdf")
tell application "Adobe InDesign CS3"
set page range of PDF export preferences to (a as string)
export document 1 format PDF type to thePath using PDF export preset "DIGITAL MAG" without showing options
end tell
tell page a of theDocument
delete text frame 1 of page a of theDocument
end tell
end tell
set a to a + 1
end tell
end repeat
end timeout
end tell
tell application "Finder"
activate
display dialog "Your PDF is ready! :-)" buttons "Ok" default button 1
end tell
end tell
The questions to add aswell are;
1, can i get the script to use the slug page information on the bottom left of the page and insert my own filename and page number aswell as a randon number?
2, if not is there a way of overwriting the the ruler postion so the text will always be in the same place no matter what?
3, is there away of putting the text on its own layer and giving it a label name?
4, if so, can it then delete the box using the label name and also remove the layer that the text box has been put on.
5, can the text box the script creates overide all of the paragraph settings, text styles, baselinegrid and always come out in the same place using the same font and same font size as a uniform?
Thanks for any help in advance
Best Regards
Rat20v
I have a Applescript that is inserted into the Script panel in indesign Cs2 and CS3,
This script, exports a pdf to PDFX1a and also a Digital Magazine Spec, thus creating 2 pdfs. It also puts a slug at the top left of the page outside the bleed area that includes the code and page number and a 5 digit random number.
This works fine on all the indesign files i create but i have a few random files sent to me and get so many problems, the script does not error but on some indesigns it put the page information in the middle of the page and also will not always is the font or font size i have asked it to use.
And on one occasion it has actually changed the running order of the text on the page and the runaround properties which is really odd.
The postion problem is because some of the indd docs i have had supplied the rulers are not set to zero top left corner.
Here is the script:
set pagerange to ""
set pagefrom to ""
set pageto to ""
set x to ""
tell application "Finder"
display dialog "Enter your page range:" default answer pagerange buttons {"OK"} default button 1
set pagerange to text returned of the result
set AppleScript's text item delimiters to {"-"}
set pagefrom to first text item of pagerange
set pageto to second text item of pagerange
end tell
tell application "Adobe InDesign CS3"
activate
set myPageNumPref to page numbering of general preferences
set page numbering of general preferences to absolute
set myPDF_prefs to PDF export preferences
tell myPDF_prefs
set page range to pagerange
set x to number of pages of page range
end tell
set theDocument to active document
set AppleScript's text item delimiters to {".indd"}
set myFileName to name of theDocument
set PageCount to number of pages of theDocument
set nameWithoutExtension to first text item of myFileName
if (count documents) is equal to 0 then
display dialog "Please open a document" buttons " OK " default button 1 with icon caution
return -128
end if
set myFolder to (choose folder with prompt "Please select the folder you want to save your PDF pages in") as string
set a to pagefrom as integer
set b to pageto as integer
set x to (b - a) + 1
set myPageNumber to (name of page a of theDocument)
-- need to initialize the array outsie of the repeat loop
tell theDocument
with timeout of 5000 seconds
repeat with x from a to b
set mynumbertest to (name of page a of theDocument) as integer
if mynumbertest is less than 10 then
set myPageNumber to "00" & (name of page a of theDocument)
else if mynumbertest is less than 100 then
set myPageNumber to "0" & (name of page a of theDocument)
else
set myPageNumber to (name of page a of theDocument)
end if
tell application "Finder"
set duplicates to {}
-- get a random number of up to 5 digits
set an_item to random number from 0 to 99999
-- this line zero-pads the random number
set an_item to text -5 thru -1 of ("00000" & an_item) as text
if an_item is not in duplicates then
set end of duplicates to an_item
end if
end tell
tell application "Adobe InDesign CS3"
activate
-- retain pointer to the opened document for later use
set theDocument to active document
--set delimiter to extension
set AppleScript's text item delimiters to ".indd"
--get the file name from ID since we are here anyway
set myFileName to name of theDocument
--Since the delimiter is the extension the first text item will remove the extension if it is part of the name
set myFileName to first text item of myFileName
--reset the delimiter to avoid potential problems
set AppleScript's text item delimiters to {".indd"}
-- add a basic text block with the filename & generated random number
tell page a of theDocument
if a mod 2 = 0 then
make new text frame with properties {contents:nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf", geometric bounds:{1, 211, -7, 301}}
else if a mod 2 is not equal to 0 then
make new text frame with properties {contents:nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf", geometric bounds:{1, 1, -7, 90}}
end if
tell parent story of text frame 1 of page a of theDocument
set applied font to "Arial"
set point size of word 1 to 8
end tell
end tell
--add the path, name and underscore together. ID ads the second underscore and page number automatically if there are more than one page to the document.
set thePath to (myFolder & nameWithoutExtension & "_" & myPageNumber & "_" & an_item & ".pdf")
tell application "Adobe InDesign CS3"
set page range of PDF export preferences to (a as string)
export document 1 format PDF type to thePath using PDF export preset "WNMEDIA" without showing options
set thePath to (myFolder & nameWithoutExtension & "_" & myPageNumber & ".pdf")
tell application "Adobe InDesign CS3"
set page range of PDF export preferences to (a as string)
export document 1 format PDF type to thePath using PDF export preset "DIGITAL MAG" without showing options
end tell
tell page a of theDocument
delete text frame 1 of page a of theDocument
end tell
end tell
set a to a + 1
end tell
end repeat
end timeout
end tell
tell application "Finder"
activate
display dialog "Your PDF is ready! :-)" buttons "Ok" default button 1
end tell
end tell
The questions to add aswell are;
1, can i get the script to use the slug page information on the bottom left of the page and insert my own filename and page number aswell as a randon number?
2, if not is there a way of overwriting the the ruler postion so the text will always be in the same place no matter what?
3, is there away of putting the text on its own layer and giving it a label name?
4, if so, can it then delete the box using the label name and also remove the layer that the text box has been put on.
5, can the text box the script creates overide all of the paragraph settings, text styles, baselinegrid and always come out in the same place using the same font and same font size as a uniform?
Thanks for any help in advance
Best Regards
Rat20v