fit page to textFrame
var doc = app.documents.add();
var page = doc.pages.item(0);
var tf = page.textFrames.add({
geometricBounds:[12.7,12.7,100,210],
contents: "Hi God, it's me - Jesus."
});
tf.paragraphs.item(0).pointSize = 42;
tf.fit(FitOptions.FRAME_TO_CONTENT);
doc.documentPreferences.pageWidth = tf.geometricBounds[3] + 12.7;
doc.documentPreferences.pageHeight = tf.geometricBounds[2] + 12.7;
var new_pw = doc.documentPreferences.pageWidth;
var new_ph = doc.documentPreferences.pageHeight;
tf.geometricBounds = [12.7,12.7,new_ph - 12.7,new_pw - 12.7];