• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Include Idml in the package script

Explorer ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

Hi Everyone,
I took this reference order from the DOM (v18.0.0.312) for packaging script. But it doesn't work as expected, throws the below mentioned error. If I re-ordered 'versionComments' to before the 'includeIdml', script creates the package with no error but the idml file is not created. But I need the 'Idml' file included in the package.
 
try{var myPackageOk = myDoc.packageForPrint(
to = myOutFolder,
copyingFonts = true,
copyingLinkedGraphics = true,
copyingProfiles = false,
updatingGraphics = true,
includingHiddenLayers = true,
ignorePreflightErrors = true,
creatingReport = true,
includeIdml = true,
includePdf = false,
pdfStyle = undefined,
useDocumentHyphenationExceptionsOnly = false,
versionComments = undefined,
forceSave = false)}catch(e){alert(e)}
 
Please suggest anything to resolve the issue or am I doing anything wrong. I am testing this code in the indesign version 17.4.
snap.png

 

 
 
 
 
 
 
 
TOPICS
Scripting

Views

787

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Guru , Nov 25, 2022 Nov 25, 2022

Try this:

try{
	var myDoc = app.activeDocument;
	var myOutFolder = new Folder("~/Desktop");
	
	var myPackageOk = myDoc.packageForPrint(myOutFolder,
			true, // copyingFonts
			true, // copyingLinkedGraphics
			false, // copyingProfiles
			true, // updatingGraphics
			true, // includingHiddenLayers
			true, // ignorePreflightErrors
			true, // creatingReport
			true, // includeIdml
			false, // includePdf
			undefined, // pdfStyle
			false, // useDocumentHyphenationExceptionsOnly
			undefined, // 
...

Votes

Translate

Translate
Community Expert , Nov 26, 2022 Nov 26, 2022

I don't see what was so difficult in this, the error itself clearly mentions what's the problem. The following line

proFiles.push(myDocNameF);
tries to push in proFiles but that isn't defined anywhere so the error. Commenting out this code successfully executes the code for me. Although the code logic would need work, as nothing is saved in the folder that we choose but is saved on the desktop, but that is a logic issue and you can easily handle it. There is much scope to improve the code quali
...

Votes

Translate

Translate
Guru ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

Try this:

try{
	var myDoc = app.activeDocument;
	var myOutFolder = new Folder("~/Desktop");
	
	var myPackageOk = myDoc.packageForPrint(myOutFolder,
			true, // copyingFonts
			true, // copyingLinkedGraphics
			false, // copyingProfiles
			true, // updatingGraphics
			true, // includingHiddenLayers
			true, // ignorePreflightErrors
			true, // creatingReport
			true, // includeIdml
			false, // includePdf
			undefined, // pdfStyle
			false, // useDocumentHyphenationExceptionsOnly
			undefined, // versionComments
			false // forceSave
		);
}
catch(e){
	alert(e);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

Hi @Kasyan Servetsky ,

 

Thanks for responding and it is working perfectly for the active document. But if it is applied in the loop for the multiple applications i get the error above mentioned.

 

Is anything wrong with myDoc variable in the batch? or something else.

 

Please help.

@Kasyan Servetsky And thanks for your contribution to the fellow people. It is very helpful to learn alot as a beginner like me. 

 

 

Thanks,

Singaaram

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

I don't understand what you mean by 'multiple applications' and 'myDoc variable in the batch'.

If you want to batch process (package) multiple documents, try this script adjusting it to your requirements.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

HI @Singaaram,

You modified the script and said that you get errors. But, you never shared the script, the error you get alongwith the missing information on how you tested it, then how can we guess what the issue is?

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 26, 2022 Nov 26, 2022

Copy link to clipboard

Copied

Yup! My bad!

Hi @Manan Joshi  @Kasyan Servetsky ,

 

Here is the modified script,

 

var myInDesignVersion = Number(String(app.version).split(".")[0]);
try{myParentFolder = Folder.selectDialog("Select the folder containing the indesign files in FILES MODIFIED ", "");}catch(e){exit(0)}
var xmlinfolder = myParentFolder;

try{mySentFolder = Folder.selectDialog("Select the folder to place the files in FILE SENT", "");}catch(e){exit(0)}

myAppFolder = myParentFolder;
myAppFolder1 = myAppFolder;
myAppFolderName = Folder(myAppFolder1).name;
var appArrays = [];

var myApps = Folder(myAppFolder1).getFiles("*.indd");
i = myApps.length;
while (i--) {
appArrays.push(myApps[i]);
}
if (appArrays.length > 0) {
for (a = 0; a < appArrays.length; a++) {
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
try{myDoc = app.open(appArrays[a]);}catch(e){alert("Application is new version! Check and run it suitable version.");exit(0)}
if (app.activeDocument.modified==true){
var myDocNameF = app.activeDocument.name;
myDoc=app.activeDocument.save(new File("/HDD1/Users/Shared/"+app.activeDocument.name));
}
var myDocNameF = app.activeDocument.name;
proFiles.push(myDocNameF);
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
var mySentFolder2 = myDocNameF.split(".indd").join("");
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
try{
var myDoc = app.activeDocument;
var myOutFolder = new Folder("~/Desktop");
var myPackageOk = myDoc.packageForPrint(myOutFolder,
true, // copyingFonts
true, // copyingLinkedGraphics
false, // copyingProfiles
true, // updatingGraphics
true, // includingHiddenLayers
true, // ignorePreflightErrors
true, // creatingReport
true, // includeIdml
false, // includePdf
undefined, // pdfStyle
false, // useDocumentHyphenationExceptionsOnly
undefined, // versionComments
false // forceSave
);
}catch(e){alert(e)}
myDoc.close(SaveOptions.no)
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2022 Nov 26, 2022

Copy link to clipboard

Copied

I don't see what was so difficult in this, the error itself clearly mentions what's the problem. The following line

proFiles.push(myDocNameF);
tries to push in proFiles but that isn't defined anywhere so the error. Commenting out this code successfully executes the code for me. Although the code logic would need work, as nothing is saved in the folder that we choose but is saved on the desktop, but that is a logic issue and you can easily handle it. There is much scope to improve the code quality, work on it.
-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

LATEST

Thank you guys,

 

Found the error and it was 'scriptPreferences.version = 8.0' issue I made it on the code. 

After clearing that, now the script works fine.

 

Thanks @Kasyan Servetsky and @Manan Joshi for the guidance. 

 

-Singaaram

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines