Home > InDesign Scripts > Fill Text Frame with Placeholder text

Fill Text Frame with Placeholder text

Great InDesign feature is that we can fill empty text box with ‘Placeholder text’. That’s very handy when we have to create template, but we don’t have text. There are few scripts for InDesign that allow us to insert different types of text, but this is my favorite: Change placeholder text by luxlucid. Also, there is very good website for creating placeholder text: Dummy Text Generator! So, let’s get started!

First example:

Let’s create two text boxes, thread them, and fill them with placeholder text. Firs, we are going to declare active document, page, and change measurement units to millimeters like this:

var myDoc = app.activeDocument;
var myPage = app.activeWindow.activePage;

myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

Good, now we can create our text boxes (of course, we can set size of text frame directly when creating, or later):

var myFirstText = myPage.textFrames.add({geometricBounds:[0,0,100,150]});
var mySecondText = myPage.textFrames.add({geometricBounds:[110,0,210,150]});

Good, now, let’s thread first frame to second like this:

myFirstText.nextTextFrame = mySecondText;

And fill them with placeholder text like this:

myFirstText.contents = TextFrameContents.placeholderText;

Great, that’s it🙂

Second example:

Now, let’s create polygon, and fill it with placeholder text. We are going to use declarations from first example. With polygon, situation is little bit different. Polygon can contain text, but we have to change content type, but, if we change it after creating, we can’t assign text to it without referencing it again. Good news is that we can assign content type in creation, so it will act like regular text frame. Variable ‘myPoints’ will hold polygon points. So, let’s first create polygon:

var myPoints = Array();
var myPolygon = myPage.polygons.add({contentType:ContentType.TEXT_TYPE});

Now, we are going to populate ‘myPoints’ with some random points:

myPoints.push([0,0]);
myPoints.push([50,20]);
myPoints.push([80,60]);
myPoints.push([40,90]);
myPoints.push([10,70]);
myPoints.push([0,40]);

Good, now we pass points to our polygon:

myPolygon.paths.item(0).entirePath = myPoints;

And at the end we fill it with placeholder text:

myPolygon.contents = TextFrameContents.placeholderText;

That’s it!

Have fun!😀

  1. September 2, 2011 at 04:33

    This is probably really simple, but I can’t seem to figure out how to get text from the clipboard to paste into a text frame I already have on my INDD page. Is it something similar to the placeholder text example? I tried replacing “placeholder” with “clipboard” and “clipboardContents” and neither worked. Is this even possible?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: