Batch create multiple Documents with js

New Here ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

I need help with a script I found and adapted for creating multiple documents from a tab separated text file.

The script creates the documents so far but it doesn't set the margin properties and I have no clue why.

 

This is the sample txt file:

210	297	20	Name1
2000	4000	300	Name2
210	297	10	Name3
220	440	20	Name4
330	200	15	Name5

 

and this the js:

var file = File.openDialog("Öffne Text Dokument", undefined, false);
var folder = Folder.selectDialog("Speicherort Dokumente");
file.open("r");
var content = file.read().split("\n");

for (var i = 0; i < content.length - 1; i++) {
    var curLine = content[i].split("\t");
    var h = curLine[0];
    var w = curLine[1];
	 var mar = curLine[2];
	 var n = curLine[3];
    docName = n + "_" + h + "×" + w;
    try {
       var newDoc = app.documents.add(false);
       newDoc.documentPreferences.pageHeight = h;
       newDoc.documentPreferences.pageWidth = w;
       newDoc.marginPreferences.properties = {top: mar,left: mar,right: mar,bottom: mar};
       newDoc.save(new File(folder + "/" + docName + " .indd"));
       newDoc.close(SaveOptions.no)
       } catch(myError){}
    }

 

Why does the "marginPreferences.properties" not work?

 

Thanks in advance for any help!

TOPICS
Scripting

Views

82

Likes

translate

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 1 Correct Answer

Participant , Dec 01, 2020 Dec 01, 2020
hi, use this line:newDoc.pages[0].marginPreferences.properties = {top: mar,left: mar,right: mar,bottom: mar};

Likes

translate

Translate

Translate
Participant ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

hi, use this line:

newDoc.pages[0].marginPreferences.properties = {top: mar,left: mar,right: mar,bottom: mar};

Likes

translate

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
New Here ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

Great Thanks!

Likes

translate

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