• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Create and Link a TextFrame for each page

New Here ,
Jul 08, 2014 Jul 08, 2014

Copy link to clipboard

Copied

New to InDesign scripting I am trying to find a way to create a text frame in a document up at the top left of each page with text that will link in between a text frame using ExtendScript Toolkit.  I tried to reference class textframe but couldn't see where to be able to manipulate the anchor to the other textframe.

Such as:

Screen Shot.png

So textframe Lorem's anchor will be dropped at the beginning of Bacon.  Currently using InDesign CC-2014.  Any help would be great thanks!  I am aware how to could create a text frame in the master but at this time I do not want to do it that way.

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 08, 2014 Jul 08, 2014

Copy link to clipboard

Copied

Hi,

Specify what you mean saying "link" and "anchor".

Creating linked textFrames or one anchored into another ==> two different stories.

Jarek

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2014 Jul 09, 2014

Copy link to clipboard

Copied

If I click on texframe Lorem to go in between the textframe Bacon. 

Screen Shot 2014-07-09 at 8.04.29 AM.png

Per this on Threaded text frames on multiple pages I am trying to make a text frame for every page at the top left corner that can be anchored to the beginning of that page's text frame.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 09, 2014 Jul 09, 2014

Copy link to clipboard

Copied

You can't anchor one text frame with another. Anchors appear in text (which generally means its inside a text frame).

Ah, but now I'm thoroughly confused because the article you pointed to doesn't have anything to do with anchoring.

So what are you trying to do?

Are the frames on the pages threaded? You can't anchor a threaded frame to another story -- only stand-alone frames can be anchored.

Are you trying to write a script to create new text frames to be anchored to an existing story? Or are you trying to work with frames that already exist?

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

@curiousgeorgex1 – unfortunately there is no method available in scripting that mimics what you can do in the UI when you drag the tiny square of the text frame to an insertion point.

In scripting we have several methods to anchor a text frame to an insertion point:

1. The add() method that would add a new text frame to an insertion point.

All options that define the position are made after.

2. Move or duplicate a character, that resembles an already anchored object to an insertion point.

3. Copy/paste an object to a selected insertion point, define position after

The easiest method is option 2, if you have prepared a textframe that is already anchored to another one at the right position. It might be more flexible to chose a position relative to the page's edges to compensate for various positions of the text frame on your page (sorry for my German UI):

Benutzerdefiniert => Position: Custom
Reletiv zum Bund => Relative to Spine

Bezugspunkt => Reference Point
Verankerte Position => Anchored Position

Verankertes Objekt => Anchored Object

x relativ zu: Seitenkante => x Relative To: Page Edge

x-Versatz => x Offset: 0

y relativ zu: Seitenkante => y Relative To: Page Edge

y-Versatz => y Offset: 0

AnchoredTextFramePositionRelativeToPage.png

With this setting the anchored text frame will always sit at the upper left corner of an even page and in the upper right corner of a odd page in a double-sided document. The parent text frame might be anywhere on the page. Here the situation with a duplicate of the text frame with the anchored one on a right page. Note: the position of the parent text frame is somewhere else on the page, but the anchored one is still on the outer upper edge of the page:

DuplicateOnRightPage.png

Now that we have prepared the "anchordness" without scripting, we could, with or without scripting, copy the only character in the parent text frame and paste it to any insertion point of a text frame on a page and the anchored text frame will be positioned on the right or left upper edge of the page.

Move your prepared text frame (the parent of the anchored one) to the pasteboard.

MoveParentToPasteboardForPreparation.png

Select the prepared text frame on the pasteboard and run the following code snippet (ExtendScript / JavaScript):

//Get the character that holds the anchored text frame:

var myAnchorCharacter = app.selection[0].characters[0];

//Get all pages in the document:

var myPages = app.documents[0].pages.everyItem().getElements();

//Loop through all pages:

for(var n=0;n<myPages.length;n++){

  

    //If the page contains text frames

    if(myPages.textFrames.length > 0){

      

        //Duplicate my anchor character before the first insertion point of the first text frame of that page:

        myAnchorCharacter.duplicate(LocationOptions.BEFORE,myPages.textFrames[0].insertionPoints[0]);

      

        };

  

    };

Before running the snippet (text frame on pasteboard is selected):

BeforeExecutingSnippet.png

After running the snippet:

AfterExecutingSnippet.png

Doing option number 1 requires far more code, but also doable.

Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Hi,

Has someone asked this:

Why do you want to create such a block? or: To put what in it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 15, 2014 Jul 15, 2014

Copy link to clipboard

Copied

LATEST

Trying to set an epub:type from InDesign.  Only on fixed layout can I get it to work but in a reflowable ePub anything that has been created in the master with a Type Special Character's Current Number will not export. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines