Force InDesign progress bar during PDF export?

When you export an InDesign file to a PDF by hand, you get a nice informative progress bar during the export. But when you script this command, you get nothing. Is there a way to make ID show the progress bar? thanks in advance –

the syntax to export a pdf looks like this -

tell application "Adobe InDesign CS3"
		export myDoc to myPath format PDF type using "[High Quality Print]"
	end tell

Hi, I’d have the same question in 2013.
Could someone answer to this ?
Thanks !

Try.

asynchronous export file active document format PDF type to pdfFile using pdfSet without showing options

instead of.

 export active document format PDF type to pdfFile using pdfSet without showing options

Thats if you just want the little indicator in the top bar.

Thank you so much :D, I wouldn’t have found this by myself.
It is then possible to check progress of this background task with for example :

tell application "Adobe Indesign CS6" to set visible of panel "Background tasks" to true

Buon giorno,
just be aware that with background export, your InDesign/Applescript is not going to “wait” for the operation to complete. If you have a step that closes the InDesign file, you will get an error. Or, you will have to put delays or some kind of check into the script to see if export is done. By doing it non-asynchronously then ID will wait until the export is done before returning to the script.

Chris

I’ve not looked at this with AppleScript. But you should have an array of background tasks that you can check in on. If it’s not empty then each should have a % done.

The asynchronous export file command returns a reference to a background task, which has properties including status and percent done.

1 Like

Thank you so much for your answers.
Do you know if it is possible to achieve the asynchronous export file command with a book ?

I don’t think so – but you can probably test it as quickly as I can.

Hi, I’m reviving this topic again. I work with InDesign files with high-resolution images, and exporting takes a lot of time. To make things worse, I have to connect to a VPN, which makes things even slower. I would like to have an idea about the export status when batching. I’m using the code below

 tell myDocument
    with timeout of 600 seconds --10mins export sometimes times out
    -- THIS WORKS
    export format PDF type to theFilePath using myPDFpreset without showing options

    -- THIS DOESN'T WORK. It stops the batching, and I get --> error "User canceled this action." number -128
    asynchronous export file format PDF type to theFilePath using myPDFpreset without showing options
    end tell

Is there something else that I need to do? Do you recommend having Background Task panel open while batching?

Try to use ignoring application responses block Instead of with timeout block. Also, were is end timeout in your script?

@KniazidisR ,
I deleted the timeout block to see if the asynchronous export file would let the script finish, but with no success.

Is ignoring application responses have the same affect as set user interaction level of script preferences to never interact?

Any application command enclosed in the body of such a block will not return a response to the script, and the script will immediately proceed to the execution of the next command.

If you don’t want to wait for the previous command to finish and continue on, then this is what you need for the speed of the script. But you need to clarify what effect you are trying to achieve. Also, I don’t have InDesign to understand better.

do you get the same error when exporting small files (that take less than a minute to export)? or only the ones that take a long time to export?

…also, as another user mentioned earlier, are you sure you’re not closing the InDesign file before the background task is finished?

I’m only getting the -128 on the timeout block when use this line code

asynchronous export file format PDF type to theFilePath using myPDFpreset without showing options

I don’t get the error when I use this line code on timeout block
export format PDF type to theFilePath using myPDFpreset without showing options

@leo_r @KniazidisR

I want to be able to view a progress meter while the pdfs are exported. I have to connect to a VPN, and occasionally I run into files that take longer to export, so it’s possible that these factors are slowing down the script or because the way I adapted it is slowing it down…

I just have basic knowledge of AS, therefore I rely heavily on this site’s specialists. Although I customized this script to suit my specifications, I am confident that it may be enhanced even more effective. The script works, but I became really interested when I saw that there was a posible way to have a progress bar while exporting to PDF and so I revived this post. The beach or spinning ball can occasionally be seen, which is a sign that the script is functioning but can also mean that Indesign is not responding. Thank you so much for trying helping me.

property myPDFpreset : missing value

set source_folder to choose folder with prompt "Choose a folder with InDesign documents."
tell application "Finder" to set theFiles to files of source_folder whose name extension is "indd"

--limit to only Indesign files
if (count of theFiles) is 0 then
	display dialog "No InDesign files to process" buttons "Cancel" default button "Cancel" with icon 0 giving up after 6
	return
end if

set the_choice to {"Smallest", "High", "1a", "Press"}
set the_choiceFav to choose from list the_choice with title "PDF Job Options" with prompt "Select a PDF Job Option" default items "Flatten PDF w/o Crop marks"

-- job options PDF
if the_choiceFav is false then
	error number -128 (* user cancelled *)
else if item 1 of the_choiceFav is "Smallest" then
	set myPDFpreset to "Smallest File Size"
else if item 1 of the_choiceFav is "High" then
	set myPDFpreset to "High Quality Print"
else if item 1 of the_choiceFav is "1a" then
	set myPDFpreset to "PDF/X-1a"
else if item 1 of the_choiceFav is "Press" then
	set myPDFpreset to "Press Quality"
end if

-- select region
set the_PROOF_choice to {"south", "north", "west", "east", "se", "ne"}
set the_PROOF_choiceFav to choose from list the_PROOF_choice with title "Regions" with prompt "Select a region to add the name to the PDFs" default items (item 1 of the_PROOF_choice)
if the_PROOF_choiceFav is false then error number -128 -- user cancelled


repeat with oneFile in theFiles
	tell application id "com.adobe.indesign"
		-- no indesign messages
		set user interaction level of script preferences to never interact
		activate
		
		set myDocument to open (oneFile as alias)
		tell myDocument
			
			
			--Check links +++++++++++++++++
			--if (count of ((links whose status is not normal) as list)) > 0 then  --for some reason it doesnt work with Indesign genereated QR codes
			if (count of ((links whose status contains link missing) as list)) > 0 then
				tell application id "com.adobe.indesign"
					set user interaction level of script preferences to interact with all
				end tell
				
				--icon choices 0=stop, iocn 1=note, icon 3=caution
				display dialog "MISSING Links" buttons {"OK"} with icon 0 default button 1 cancel button 1 giving up after 300 --5min
				
				
			else if (count of ((links whose status contains link out of date) as list)) > 0 then
				tell application id "com.adobe.indesign"
					set user interaction level of script preferences to interact with all
				end tell
				display dialog " MODIFIED Links." buttons {"OK"} with icon 0 default button 1 cancel button 1 giving up after 300 --5min
				--return
			end if
			
			--+++++++++++++++++
			--Check if there are any text boxes with overset text
			set thereIsTextOverflow to ((overflows of parent story of every text frame) contains true)
			if thereIsTextOverflow then
				display dialog "Overflow Text Boxes." buttons {"OK"} with icon 0 default button 1 cancel button 1 giving up after 300 --5min
			end if
			
			--++++++++++++++++++++++
			--check missing fonts
			set myfontprop to properties of every font
			set font_list to {}
			repeat with i from 1 to the number of myfontprop
				set this_font_item to item i of myfontprop
				set myfontname to name of this_font_item as string
				set fontstatus to status of this_font_item as string
				set font_list to font_list & fontstatus
			end repeat
			if font_list contains "not available" then
				tell application id "com.adobe.indesign"
					set user interaction level of script preferences to interact with all
				end tell
				display dialog " Missing Font." buttons {"OK"} with icon 0 default button 1 cancel button 1 giving up after 300 --5min
			else if font_list contains "substituted" then
				tell application id "com.adobe.indesign"
					set user interaction level of script preferences to interact with all
				end tell
				display dialog "A Font has been substituted or it is missing." buttons {"OK"} with icon 0 default button 1 cancel button 1 giving up after 300 --5min
			end if
			
			----============
			set source_folder to file path of myDocument
			set theName to name of myDocument
			
			set text item delimiters of AppleScript to {"_"}
			set theShortName to text 1 thru text item -2 of theName
			--text 1 thru text item -2 is every character from the first character to the second to last text item
			set text item delimiters of AppleScript to ""
			
			tell application "Finder"
				if (exists folder "PDF" of folder source_folder) is false then
					make folder at source_folder with properties {name:"PDF"}
				end if
			end tell
			
			
			tell application id "com.adobe.indesign"
				repeat with x from 1 to count pages of myDocument
					set thePageName to name of page x of myDocument
					set page range of PDF export preferences to thePageName
					
					--section number must have 3 digits
					set threeDigitPageName to text -3 thru -1 of ("00" & thePageName)
					--text -3 thru -1 are the last 3 characters*)					
					set theFilePath to source_folder & "PDF:" & theShortName & "_" & threeDigitPageName & "_" & the_PROOF_choiceFav & ".pdf" as string
					
					
					
					--EXPORT PDF
					tell myDocument
						with timeout of 600 seconds --10mins
							-- Below line code works
							export format PDF type to theFilePath using myPDFpreset without showing options
							
							--export with progress indicator- Below 2line codes works DO NOT WORK I get an error -128
							asynchronous export file myDocument format PDF type to theFilePath using myPDFpreset without showing options
							--asynchronous export file format PDF type to theFilePath using myPDFpreset without showing options
						end timeout
					end tell
					
				end repeat
			end tell
			
			close myDocument saving no
			
			tell application id "com.adobe.indesign"
				set user interaction level of script preferences to interact with all
			end tell
			--====
			
		end tell
	end tell
end repeat

Try following instead of corresponding fragment if the theFilePath is HFS path:
 
 

tell myDocument
	with timeout of 600 seconds --10mins
		
               asynchronous export format PDF type to theFilePath using myPDFpreset without showing options
		
		repeat -- repeat until current export is finished
			try
				delay 1
				alias theFilePath
				exit repeat
			end try
		end repeat
		
	end timeout
end tell

 

close myDocument saving no

as mentioned earlier, when using asynchronous export, you have to wait until the background task is finished before closing the document. if you attempt to close the document while the task is still running, you’ll get exactly -128 error.

you need to poll the task for completion (or existence) and only close the document when the task is done.

Exactly. I inserted the infinite repeat loop for this reason.

Also, the OP has strange code, 2-layer (nested) tell application id “com.adobe.indesign” blocks. The code should be refined to not meet the strange errors. I have not the InDesigner to refine the whole script.