Skip to main content
Inspiring
July 26, 2010
Question

Insert text after a specific text (top insertion point of page)

  • July 26, 2010
  • 1 reply
  • 1134 views

Hello guys,

How can add a flag (a simple text) on top of page after a specific flag (unique piece of text). Let me try to explain:

I am inserting a flag on top of a each page of document.

var myText={flag1};  

myDoc.pages.textFrames.itemByName("main").insertionPoints.item(0).properties = { appliedCharacterStyle : "pbBlank_CS", contents:myText};

In second go, I am again inserting another flag on top of pages:

var myText={flag2};  

myDoc.pages.textFrames.itemByName("main").insertionPoints.item(0).properties  = { appliedCharacterStyle : "pbBlank_CS", contents:myText};

The order I am expecting should be

{flag1}{flag2} but on some pages it appears in reverse form

{flag2}{flag1} which is not expected. I am thinking following way to keep the correct order:

1. Finding "}" on top , like {flag1} text start text start .............. and then inserting my second flag {flag2} to it to get the correct order {flag1}{flag2} text start text start.

The reason why I would like to search for last "}" as there may as many as flags need added to top of page something like {flag1}{flag2}{flag3}{flag4} etc. This will ensure me to have the correct order.

Hope I am making sense.

Any thoughts in this regard will be highly appreciated.

Regards,

--PC

This topic has been closed for replies.

1 reply

tomaxxi
Inspiring
July 26, 2010

Hey!

Can't you insert flags backwards?

tomaxxi

PankChatAuthor
Inspiring
July 26, 2010

Well I did tried it earlier but it was too failing in few cases so I dropped the idea. Can't remember what was the actual error, something sure again related with the order of appearance.

I narrowed down to searching of already available flag {flag1} on top and insert the next flag after it {flag2}. I believe this can be done but I am failing with the syntax.

Thanks for hep.

PankChatAuthor
Inspiring
July 26, 2010

It seems that itemByRange() is not a solution too as text {flag1} is a variable text and can reach up to {flag2000} (basically the page no.).

Darn it cant we search for specific text "}" on top of page using insertion points or shall I drop the idea?

Any suggestion will be great.