11 Replies Latest reply: Apr 26, 2012 1:51 PM by tonyxamax RSS

    how do i place a textframe central to the artboard

    tonyxamax

      This is my very first attempt at a script:

      all tips are greatfully recieved

       

       

       

       

      * this script will prompt  the user for a file name and location and then

          save the current file as a .pdf with secure save options*/

      var curDoc = app.activeDocument;

      var destName = prompt ("Enter a Filename Daniel", "", "Save With  Security");

      var destFolder = Folder.selectDialog('Select which folder to save to :');

      saveFileToPDF(destFolder+ '/' + destName); // not sure if i need this here ?

       

       

       

       

      /* this will annotate the document with a breadcrumb trail

          then resave the file with the same security settings*/

       

       

       

       

                                              // i need to find a method of placing this central to the artboard, but as the text has random dimensions its proving difficult also there are multiple artboards

      var pointTextRef = curDoc.textFrames.add();

      pointTextRef.contents = curDoc.name + '  ' + curDoc.fullName;

      pointTextRef.top = 735;

      pointTextRef.left = 20;

      saveFileToPDF(destFolder+ '/' + destName); // i need this here

       

       

      //

       

      function saveFileToPDF (dest) {

      var doc = app.activeDocument;

      if ( app.documents.length > 0 ) {

      var saveName = new File ( dest );

      saveOpts = new PDFSaveOptions();

      saveOpts.requirePermissionPassword = true;

      saveOpts.permissionPassword = "test";

      doc.saveAs( saveName, saveOpts );

       

       

      }

      }

       

      i can do the math of (artboard width)-(text width) / 2 is start point of text but how do i find out the text width and the artboard width?

       

      Message was edited by: tonyxamax