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

Batch create multiple Documents with js

New Here ,
Dec 01, 2020 Dec 01, 2020

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
346
Translate
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};
Translate
Participant ,
Dec 01, 2020 Dec 01, 2020

hi, use this line:

newDoc.pages[0].marginPreferences.properties = {top: mar,left: mar,right: mar,bottom: mar};
Translate
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
LATEST

Great Thanks!

Translate
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