PDA

View Full Version : Unicode Problem with 10.5.8 from 10.4.11?


emills
06-29-2010, 01:57 PM
At my company we run an AppleScript that retrieves information from our database program and uses it to place PDF images on the correct layer & page of InDesign documents. We recently upgraded from 10.4.11 to 10.5.8 and have run into some problems.

Now the script is only partially working. The script cannot recognize any page beyond 11. By this I mean all PDF images place correctly on a given layer for pages 1-10. For any page after 11 the script reports that it cannot get that page.

I believe this is because the newer version of AppleScript is completely Unicode text based but the older script is not. How do I get the script to recognize the numbers 11 and above?

Here is an excerpt of the script that I believe is causing the issue. Thank you:

--pageField of rDatabase = Page Number from database program (entered as plain text)
--docName = Name of INDD file
--imageBox = Frame of INDD Page
--imagePath = Location of PDF file

set nPage to (pageField of rDatabase) as number
placeImageFile(docName, nPage, imageBox, imagePath)

on placeImageFile(xDoc, nPage, imageBox, imagePath)
set imagePath to imagePath as string
tell application "Adobe InDesign CS4"
if {Unicode text, string, number, integer} contains (class of xDoc) then set xDoc to document xDoc
if nPage is not equal to "" then set xDoc to page nPage of xDoc
tell xDoc
if {integer, string, Unicode text} contains {class of imageBox} then
try
set placeRef to page item imageBox
on error
set placeRef to page item imageBox of all page items
end try
else
set placeRef to imageBox
end if
end tell
tell placeRef
place imagePath
end tell
end tell
end placeImageFile

tw
07-01-2010, 11:51 AM
This is, of course, impossible to test without the greater context and some examples to play with. I can show you how to debug it, though. add lines like the following (in blue) into the script, and run it. applescript will throw up dialogs to show you the relevant info.

also, I recommend that in your first line you use "... as integer" rather than "... as number". 'number' is an abstract class that really shouldn't be used unless you're not sure whether you want an integer or a real, and in this case you surely want an integer.

on placeImageFile(xDoc, nPage, imageBox, imagePath)
set imagePath to imagePath as string
tell application "Adobe InDesign CS4"
display dialog "Class of xDoc: " & (class of xDoc) as text
if {Unicode text, string, text number, integer} contains (class of xDoc) then set xDoc to document xDoc
display dialog "Class of nPage, nPage: " & (class of nPage) as text & ", " & nPage
if nPage is not equal to "" then set xDoc to page nPage of xDoc
display dialog "Class of imageBox: " & (class of imageBox) as text
tell xDoc
if {integer, string, Unicode text} contains {class of imageBox} then
try
set placeRef to page item imageBox
on error errstr
tell application "Adobe InDesign CS4" to display dialog "level 1 error thrown: " & errstr
try
set placeRef to page item imageBox of all page items
on error
tell application "Adobe InDesign CS4" to display dialog "level 2 error thrown: " & errstr
end try
end try
else
set placeRef to imageBox
end if
end tell
tell placeRef
place imagePath
end tell
end tell
end placeImageFile

My guess would be that (for some reason) the

emills
07-07-2010, 07:00 AM
Thanks. I did manage to do some debugging/displaying variables and was able to locate all the necessary classes & variables to ultimately rewrite the script without the complexities that were necessary in the older OS & Script Editor. Working perfectly now.