Copy link to clipboard
Copied
I have a script I've been using since 2010 that will not work with InDesign 2025. It saves the InDesign file to single page PDFs with the file name being the page number. I have no knowledge of scripts (only how to use them). Can anyone help diagnose what needs to change?
tell application "Adobe InDesign 2025"
set doc_name to active document
set doc_pages to every page of doc_name
set file_name to text returned of (display dialog "Please enter a File Name:" default answer "" buttons {"Cancel", "Ok"} default button 2 with icon 1)
set pdf_style to name of every PDF export preset
set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset") as string
set folder_path to (choose folder with prompt "Please select your destination folder...") as string
repeat with anItem in doc_pages
set page_number to name of anItem as string
count characters of page_number
if length of page_number is 1 then
set new_number to text -3 thru -1 of ("00" & page_number)
end if
if length of page_number is 2 then
set new_number to text -3 thru -1 of ("0" & page_number)
end if
if length of page_number is 3 then
set new_number to page_number
end if
if length of page_number is 4 then
set new_number to page_number
end if
set PDF_name to folder_path & file_name & "_" & new_number & ".pdf"
set page range of PDF export preferences to page_number
tell doc_name
export format PDF type to PDF_name using export_style without showing options
end tell
end repeat
beep 3
display dialog "Your PDFs were successfully exported" buttons {"Done"} default button 1
end tell
Sure!
--Version 4.0 01/19/2022
--Version 5.0 10/30/2024
(*
The following changes were made for ID 2025
tell doc_name
export format PDF type to PDF_name using export_style without showing options
-nd tell
TO
try
export doc_name format PDF type to file PDF_name using export_style without showing options
on error errMsg
display dialog "Error exporting PDF: " & errMsg buttons {"OK"} default button 1
end try
*)
--Version relies on Section prefix property turned out to be the key from v.25.
--Without this S
...Copy link to clipboard
Copied
Looks like Apple Script not UXP
Try this
tell application "Adobe InDesign 2025"
if not (exists active document) then
display dialog "No document is currently open." buttons {"OK"} default button 1
return
end if
set doc_name to active document
set file_name to text returned of (display dialog "Please enter a File Name:" default answer "" buttons {"Cancel", "Ok"} default button 2 with icon caution)
set pdf_style to name of every PDF export preset
if pdf_style is {} then
display dialog "No PDF export presets found." buttons {"OK"} default button 1
return
end if
set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset" without multiple selections allowed and empty selection allowed) as string
if export_style is "false" then return
set folder_path to POSIX path of (choose folder with prompt "Please select your destination folder...")
set doc_pages to every page of doc_name
repeat with anItem in doc_pages
set page_number to name of anItem as string
if (count of characters of page_number) is 1 then
set new_number to "00" & page_number
else if (count of characters of page_number) is 2 then
set new_number to "0" & page_number
else
set new_number to page_number
end if
set PDF_name to folder_path & file_name & "_" & new_number & ".pdf"
set page range of PDF export preferences to page_number
export doc_name format PDF type to PDF_name using export style export_style without showing options
end repeat
beep 3
display dialog "Your PDFs were successfully exported" buttons {"Done"} default button 1
end tell
Copy link to clipboard
Copied
Thank you so much for your help. After I posted, the original script-writer sent me a new one. I truly appreciate your help!
Copy link to clipboard
Copied
Ok cool - thanks for letting us know
do you mind sharing the updated code - it could help in the future
Copy link to clipboard
Copied
Sure!
--Version 4.0 01/19/2022
--Version 5.0 10/30/2024
(*
The following changes were made for ID 2025
tell doc_name
export format PDF type to PDF_name using export_style without showing options
-nd tell
TO
try
export doc_name format PDF type to file PDF_name using export_style without showing options
on error errMsg
display dialog "Error exporting PDF: " & errMsg buttons {"OK"} default button 1
end try
*)
--Version relies on Section prefix property turned out to be the key from v.25.
--Without this Section prefix property change, the script did not pay attention to the "C" in front of the page numb
--changed section prefix from a looop to "set include section prevfix of *every section* in order to avoid counting
with timeout of 86400 seconds
tell application "Adobe InDesign 2025"
set doc_name to active document
set doc_pages to every page of doc_name
set thecount to count of pages of doc_name
repeat with i from 1 to thecount - 1
set include section prefix of every section of doc_name to true
end repeat
set file_name to text returned of (display dialog "Please enter a File Name:" default answer "" buttons {"Cancel", "Ok"} default button 2 with icon 1)
set pdf_style to name of every PDF export preset
set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset") as string
set folder_path to (choose folder with prompt "Please select your destination folder...") as string
repeat with anItem in doc_pages
set page_number to name of anItem as string
count characters of page_number
if length of page_number is 1 then
set new_number to text -3 thru -1 of ("00" & page_number)
end if
if length of page_number is 2 then
set new_number to text -3 thru -1 of ("0" & page_number)
end if
if length of page_number is 3 then
set new_number to page_number
end if
if length of page_number is 4 then
set new_number to page_number
end if
set PDF_name to folder_path & new_number & "_" & file_name & ".pdf"
set page range of PDF export preferences to page_number
try
export doc_name format PDF type to file PDF_name using export_style without showing options
on error errMsg
display dialog "Error exporting PDF: " & errMsg buttons {"OK"} default button 1
end try
end repeat
beep 3
display dialog "Your PDFs were successfully exported" buttons {"Done"} default button 1
end tell
end timeout