Skip to main content
KlausFriese
Inspiring
January 11, 2017
Answered

Embed Textframe in Textframe and add more content ..

  • January 11, 2017
  • 2 replies
  • 586 views

Hi,

I'm currently working with textframes and I like to add inline textframes and more paragraphs.

My problem: If I create an inline textframe and add more text to the content after that the inline textframe disappears.

Example code:

var content = "Paragraph\nLine 1\nLine 2\r";

var doc = app.activeDocument;

var tf1 = doc.pages[0].textFrames.add({geometricBounds: ['12.7mm','12.7mm','200mm', '200mm']}); 

tf1.contents = content; 

     

var insertRef = tf1.paragraphs[0].insertionPoints[-1];

var tf2 = insertRef.textFrames.add(); 

   

tf2.geometricBounds = [tf2.geometricBounds[0], tf2.geometricBounds[1], tf2.geometricBounds[2] + 50, '50mm']; 

tf2.contents = content; 

tf1.contents = tf1.contents + content;

If I remove the last line I see the inline textframe - if I add it again, the inline textframe is gone. Any idea why this happens?

Thanks

Klaus

This topic has been closed for replies.
Correct answer Loic.Aigon

Hi Klaus,

tf1.insertionPoints[-1].contents  = content;

2 replies

tpk1982
Legend
January 11, 2017

try this..

var content = "Paragraph\nLine 1\nLine 2\r";

var doc = app.activeDocument;

var tf1 = doc.pages[0].textFrames.add({geometricBounds: ['12.7mm','12.7mm','200mm', '200mm']});

tf1.contents = content;

    

var insertRef = tf1.paragraphs[0].insertionPoints[-1];

var tf2 = insertRef.textFrames.add();

  

tf2.geometricBounds = [tf2.geometricBounds[0], tf2.geometricBounds[1], tf2.geometricBounds[2] + 50, '50mm'];

tf2.contents = content;

tf2.contents = tf2.contents + content;

KlausFriese
Inspiring
January 11, 2017

This would add more text to the embeded textframe...

Loic.Aigon
Loic.AigonCorrect answer
Legend
January 11, 2017

Hi Klaus,

tf1.insertionPoints[-1].contents  = content;

KlausFriese
Inspiring
January 11, 2017

Great, that works!

Thanks