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

[JS][CS4] Minimum document size in javascript?

Explorer ,
Aug 17, 2011 Aug 17, 2011

Copy link to clipboard

Copied

Hello,

I've been searching for days with no luck and am hoping someone can help me. Is there a minimum document size javascript will allow you to create using an INDD script?  With some trial and error I've been able to use javascript to create a document that is 1.02" x 1.02" but no smaller, yet if I manually create a document smaller than that it works fine. Does anyone know a way around this issue or is it a known limitation?

The document I try to create has no masters, and no margins. The error produced in javascript is "Data is out of range".

Any help is greatly appreciated!

Thanks,

Lindsay

TOPICS
Scripting

Views

1.6K

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

Guide , Aug 18, 2011 Aug 18, 2011

Hi Lindsay,

In ID CS4 the minimum document page size is 1pt × 1pt. Setting such tiny values through scripting can fail because you have to inhibit the default margin preferences. The problem is that the Document.marginPreferences property does not work during document construction—I think this is a bug. So the following code does not work:

// DOES NOT WORK -- BUG?

app.documents.add(true, undefined,
     {
     marginPreferences: {top:0, left:0, bottom:0, right:0,columnGutter:0,columnCount:1},
     doc

...

Votes

Translate

Translate
Guide ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

Hi Lindsay,

In ID CS4 the minimum document page size is 1pt × 1pt. Setting such tiny values through scripting can fail because you have to inhibit the default margin preferences. The problem is that the Document.marginPreferences property does not work during document construction—I think this is a bug. So the following code does not work:

// DOES NOT WORK -- BUG?

app.documents.add(true, undefined,
     {
     marginPreferences: {top:0, left:0, bottom:0, right:0,columnGutter:0,columnCount:1},
     documentPreferences: {pageWidth:'1pt', pageHeight:'1pt'},
     });

The only solution I know is to temporarily change the application margin preferences:

// Backup the default app margin prefs
// ---
var bkp = app.marginPreferences.properties;

// Change the margin prefs to allow small document size
// ---
app.marginPreferences.properties = {
     top:0, left:0, bottom:0, right:0,
     columnGutter:0, columnCount:1
     };

// Create a 'minimal' document
var doc = app.documents.add(true, undefined,
     {documentPreferences: {pageWidth:'1pt', pageHeight:'1pt'}}
     );

// Restore the default app margin prefs
// ---
app.marginPreferences.properties = bkp;

@+

Marc

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 ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

Hi Marc,

Thank you so much!  I figured (and was hoping) there was some way to force the change. Thank you for taking the time to answer!!

Lindsay

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
Contributor ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

LATEST

Hi.

Here is another solution, applied margin to also Master Spread.

var doc = app.documents.add(); doc.marginPreferences.properties = {top:0,right:0,bottom:0,left:0}; // this part doesnt work?? // var mst_page = doc.masterSpreads[0].pages.everyItem(); // mst_page.marginPreferences.properties = {top:0,right:0,bottom:0,left:0}; var mst_page_1 = doc.masterSpreads[0].pages[0]; mst_page_1.marginPreferences.properties = {top:0,right:0,bottom:0,left:0}; var mst_page_2 = doc.masterSpreads[0].pages[1]; mst_page_2.marginPreferences.properties = {top:0,right:0,bottom:0,left:0}; doc.documentPreferences.pageWidth = '1pt'; doc.documentPreferences.pageHeight = '1pt';

mg

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