Skip to content

Instantly share code, notes, and snippets.

@ryanlfoster
Forked from ff6347/fit_page_to_tf.jsx
Created May 6, 2013 19:46
Show Gist options
  • Save ryanlfoster/5527619 to your computer and use it in GitHub Desktop.
Save ryanlfoster/5527619 to your computer and use it in GitHub Desktop.
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];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment