3 Replies Latest reply on Aug 18, 2011 6:03 PM by milligramme

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

    booyajamo Level 1

      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

        • 1. Re: [JS][CS4] Minimum document size in javascript?
          Marc Autret Level 4

          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

          • 2. Re: [JS][CS4] Minimum document size in javascript?
            booyajamo Level 1

            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

            • 3. Re: [JS][CS4] Minimum document size in javascript?
              milligramme Level 3

              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

              1 person found this helpful