Skip to main content
Participant
February 16, 2023
Answered

Export all conditional text iterations to a pdf

  • February 16, 2023
  • 1 reply
  • 620 views

I have a document with over 70 pages of images that need 20 different text combinations for each page. I have my conditional text all set up and was looking for a way to easily export all the different combinations to a .pdf.

 

I found this post which is exactly what I want to do. Here is the script from the post:

 

var nameOfThePDFExportPresetYouWantToUse = '[High Quality Print]' //please don't forget to set!

 

var currDoc = app.activeDocument;

var currFilePath = currDoc.filePath.absoluteURI + '/';

var currFileName = currDoc.name.replace(/.indd/, '');

var currConditions = currDoc.conditions;

//set all conditions visible to false

currConditions.everyItem().visible = false;

 

l = currConditions.length;

//cycle thru conditions

while(l--){

currCondition = currConditions;

//set actual condition visible to true

currCondition.visible = true;

 

currConditionName = currCondition.name

//set pdfName

var exportTo = File(currFilePath + currFileName + '_' + currConditionName +'.pdf');

 

//Have a look here:

//export PDF. to choose backgroundexport. use the second line of code

currDoc.exportFile(ExportFormat.PDF_TYPE, exportTo,false, nameOfThePDFExportPresetYouWantToUse);

//currDoc.asynchronousExportFile(ExportFormat.PDF_TYPE, exportTo,false, nameOfThePDFExportPresetYouWantToUse);

 

 

//set actual condition visible to false

currCondition.visible = false;

}

 

I copied the script from this post, but am getting the following error when I try to run it:

Error Number: 55

Error String: Object does not support the property or method 'visible'

 

I am a complete novice when it comes to scripting, so I am unable to trouble shoot it at all. The error line is in orange. Any help would be appreciated!

This topic has been closed for replies.
Correct answer brian_p_dts

Try adding [l] to the end of the line: 

currCondition = currConditions[l];

 

Forum migration a while back stripped iterators from old code. 

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
February 16, 2023

Try adding [l] to the end of the line: 

currCondition = currConditions[l];

 

Forum migration a while back stripped iterators from old code. 

Robert at ID-Tasker
Legend
February 16, 2023

Just wanted to mention this 😉