this apple script has stopped working in adobe indesign 2023, it prints a blank page, as…
- User
this apple script has stopped working in adobe indesign 2023, it prints a blank page, as though its not placing the picture: on open these_items repeat with this_item in these_items
tell application "Adobe InDesign 2023" activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}} try place alias (this_item) on myRectangle fit rectangle 1 given center content on error -- do your stuff end try end tell end tell end tell end repeatend open
- Assistant
It's difficult to determine the exact issue without more information, but here are a few possible reasons why your AppleScript may not be working in Adobe InDesign 2023:
-
Compatibility issue: Adobe InDesign 2023 may have changed the scripting interface or functionality, causing your script to no longer work. You may need to update your script to be compatible with the new version.
-
File path issue: Make sure that the file path provided in the "place alias" line is correct and that the file is accessible. If the file path is incorrect or the file cannot be found, it may result in a blank page.
-
Error handling: The "on error" block in the "place alias" line may be suppressing any error messages or actions. Check if there are any errors occurring during the script execution by removing the "on error" block temporarily.
-
Object creation: Ensure that the "make rectangle" and "fit rectangle" commands are creating and manipulating the correct objects. Verify the properties and bounds of the rectangle object to make sure it is placed correctly.
-
- User
can you alter the script to try if it works?
- Assistant
Certainly! Here's an altered version of your script that includes some additional error handling and logging to help troubleshoot the issue:
on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}} try set placedObj to place alias (this_item) on myRectangle fit placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open - User
error placing PDF file: Missing required parameter 'file name' for method 'place'
- Assistant
Apologies for the oversight. It seems that I missed providing the file name in the
placecommand.Here's the corrected version of the altered script:
on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}} try set placedObj to place (this_item as alias) on myRectangle fit placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open - User
this works now. when creating the rectangle it has a black keyline, is there any way if setting stroke to none?
- Assistant
Certainly! You can set the stroke of the rectangle to none by adding the appropriate properties to the
make rectangleline. Here's the modified script:on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}, stroke color:none} try set placedObj to place (this_item as alias) on myRectangle fit placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open - User
Adobe InDesign 2023 got an error: Invalid parameter. (30477)
- Assistant
Apologies for the error. It seems that the
stroke color:nonesyntax I provided is not valid in Adobe InDesign 2023.To set the stroke of the rectangle to none, you can use the
stroke color:{none}syntax instead. Here's the modified script:on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}, stroke color:{none}} try set placedObj to place (this_item as alias) on myRectangle fit placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open - User
Adobe InDesign 2023 got an error: Invalid parameter. (30477)
- Assistant
I apologize for the inconvenience. It appears that specifying
stroke color:{none}is not valid in Adobe InDesign 2023 scripting.To work around this issue, you can try explicitly setting the stroke properties of the rectangle after creating it. Here's the modified script:
on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}} try set stroke color of myRectangle to "None" set placedObj to place (this_item as alias) on myRectangle fit placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open - User
syntax error on " Expected expression but found unknown token.
- Assistant
Apologies for the error. It seems that the syntax I provided for setting stroke color to none is not valid in Adobe InDesign 2023 scripting.
Here's an alternate method you can try using the
set strokecommand to remove the stroke from the rectangle:on open these_items repeat with this_item in these_items try tell application "Adobe InDesign 2023" -- Check if InDesign is running if not (exists process "Adobe InDesign 2023") then display alert "Adobe InDesign 2023 is not running." return end if activate -- Document Creation set myDoc to make document tell myDoc set horizontal measurement units of view preferences to millimeters set vertical measurement units of view preferences to millimeters tell document preferences of it set page height to "283mm" set page width to "226mm" set page orientation to portrait end tell -- Import pdf tell page 1 of myDoc set myRectangle to make rectangle with properties {geometric bounds:{0, 226, 283, 0}} try set stroke of myRectangle to nothing set placedObj to place (this_item as alias) on myRectangle fit contents of placedObj given center content on error errMsg display alert "Error placing PDF file: " & errMsg end try end tell end tell end tell on error errMsg display alert "Error occurred: " & errMsg end try end repeat end open