fabianmoronzirfas
10/2/2012 - 4:53 PM

this script centers a sentence on a page

this script centers a sentence on a page

/*
this script centers a sentence on a page
vertically and horizontally
written by @fabiantheblind
*/

// create a doc with a size of 200 w and h
var doc = app.documents.add({
        documentPreferences:{
                pageWidth : 200,
                pageHeight: 200
            }
        });
/*    
create a textframe with a content and the 
textframe option set to 
Center
*/

var tf = doc.pages.item(0).textFrames.add({
        geometricBounds:[25,25,175,175],
        contents: "An einem Morgen später Regenfälle",
        textFramePreferences:{
            verticalJustification: VerticalJustification.CENTER_ALIGN
            }
        });
    
    
var firstPar = tf.paragraphs.item(0); // get the first paragraph
// set some properties
firstPar.properties = {
                pointSize: 23,
                justification : Justification.CENTER_ALIGN
                };


// we are done!