IDCS5 JS: problem with the "captured" text lose formatting

Hi all

Excellent script from Peter Kahrel allows us to convert the notes in endnotes dynamic in IDCS5 after which, we use some of our own JS to enter this text, put it in an orange box and then delete the original text of notes. This works very well but have just realized that the formatting (italics) who was in the original notes text does not survive moved to the new text box. Italics is still protected by a character style.

Our code;

//searches for endnotes, puts them in a orange box and adds the "Endnotes" heading
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeFootnotes = true;

var myDoc = app.activeDocument
var myPara = myDoc.paragraphStyles.item ("Endnotes");

// Find the text & capture its contents to a variable
app.findGrepPreferences.appliedParagraphStyle = "Endnotes"
origText1 = app.activeDocument.findGrep (); 

//check if any Endnotes are found, nothing happens if not
if(origText1.length!=0)
{
newText1=origText1[0].contents;

//adds new text frame on 1st page of doc
var myTextFrame1 = myDoc.pages.item(0).textFrames.add();
myTextFrame1.geometricBounds = ["6p", "6p", "36p", "36p"];

// Apply the objectStyle to frame
var myOStyle = myDoc.objectStyles.item("Endnote box");
myTextFrame1.applyObjectStyle(myOStyle); 

//add captured text to text box
myTextFrame1.contents = ("Endnotes\r" + newText1);

var myDelete = myDoc.paragraphStyles.add ({name: "Endnotes1", basedOn: myPara});

// Loop to apply paragraph style to text
var length = myTextFrame1.paragraphs.length

for (var i =0; i<=length-1; i++ )
{
//apply para style to new frame contents
var myStory = myTextFrame1.paragraphs[0].parentStory
myStory.paragraphs[i].appliedParagraphStyle = "Endnotes1"
}

//removes original text
app.findGrepPreferences.appliedParagraphStyle = "Endnotes"
app.changeGrepPreferences.changeTo="";
app.documents.item(0).changeGrep();

 // remove Endnotes1 paragraph style and replace with Endnotes style
myDelete.remove (myPara)
}
    
else
{
 }

As you can see enter us the text to a variable using GREP and that place in a new box (preceded by a heading). Make us a copy of the para style 'notes', which allows you to style the copied text, remove any style with the original style (the original formulation) and then delete the new style replacing wiith the original style so that the copied text back to style 'notes' new para. I don't know there's a better way, but it works for what we want - at least I thought that this was the case.

Any thoughts appreciated gratefully. I searched the forum but couldn't find anything relevant. What Miss me?

Thank you

Iain

Why don't you just "move" the texts found for the box of endNote?

I suggest the following approach (not tested, project code):

function moveEndnotesInBox()
//--------------------------------------
// Searches for endnotes, puts them in a orange box and adds the "Endnotes" heading
{
    // Preset findGrep
    // ---
    app.findGrepPreferences = null;
    app.findChangeGrepOptions.includeFootnotes = true;
    app.findGrepPreferences.appliedParagraphStyle = "Endnotes";

    // Find the text(s)
    // ---
    var doc = app.activeDocument,
        foundTexts = doc.findGrep(),
        i = foundTexts.length;

    // If no 'Endnotes' text is found, return
    // ---
    if( !i ){ alert("No endnote found"); return; }

    // Creates a new text frame on 1st page w/ specific
    // bounds, and preset contents
    // ---
    var tf = doc.pages[0].textFrames.add(
        {
        geometricBounds: ['6p', '6p', '36p', '36p'],
        contents: "Endnotes\r"
        });

    // Preset obj and parag. style
    // ---
    tf.appliedObjectStyle = doc.objectStyles.itemByName("Endnote box");
    tf.parentStory.paragraphs.everyItem().appliedParagraphStyle = "Endnotes";

    // Backup the last insertion point index
    // ---
    var    ips = tf.parentStory.insertionPoints,
        ipx = ips.length - 1;

    // Loop through foundTexts and move texts to tf
    // (IMPORTANT: from the last to the first item to preserve Text indices)
    // ---
    while( i-- )
        {
        foundTexts[i].move(LocationOptions.AFTER, ips[ipx]);
        }
}

moveEndnotesInBox();

Of course you must still deal with the possible lack of returns of paragraph or 'ghost' reference markers. I do not exactly know the context, but it seems not complicated.

Hope that helps.

@+

Marc

Tags: InDesign

Similar Questions

  • Problem with the Oracle text markup

    Hello

    I have a problem with the Oracle text markup.

    I am looking for keywords in a text which is composed by a question and answer.
    Here is the structure of my text:
    & lt; div class = 'question' & gt;
    & lt; a & gt; the title of my question & lt; /a & gt;
    & lt; div class = "reply & gt;
    content of response
    & lt; / div & gt;
    & lt; / div & gt;

    It is possible to search those keywords in the question or answer only. For this, I use the stored procedure:

    {call CTX_DOC. MARKUP)
    index_name = >?
    textkey = >?
    text_Query = >?
    restab = >?
    query_id = >?
    startTag = >?
    (EndTag = >?)}

    _with these parameters: _

    index_name = < my index >
    textkey = < id for the search text >
    text_Query = < a query containing the keywords >
    restab = < a table SQL to store the marked text >
    query_id = < id >
    startTag = ' < span class =-"highlight\" >. "
    EndTag = "</span >.

    The markup should be done only in the place you want (question, answer, or both).
    The markup is good when I search a keyword throughout the text, in the question or answer only.
    * If I search two key words in the question or answer, the markup is bad *.

    _Example: __
    I am looking for the words "* Internet *" in question only.
    Here's the query passed to the stored procedure:
    + * text_query * = 'service & internet' INPATH (//div[@class = 'question'] / has) +.

    In the question, these words are well marked.
    In response, only the first word is marked.

    * Why the first keyword is also marked in the response while the query specifies a search in question only? *

    The same problem appears when I search for the same keywords in the response only.
    In this case, in the answer, these words are marked as well.
    In the issue, only the first word is marked.

    Thanks for your help

    Edited by: user11088931 Apr 21. 2009 06:17

    Try text_query = (service & internet) INPATH (//div/a)

    Single quotes in a query do nothing. I think that your request has been treated as

    Service & (internet INPATH (//div/a))

  • Problem with the bulleted text

    I am new to InDesign and the suite CS4 and am having a problem with the flow of text in a bulleted list in a trifold brochure.

    I work with a background image to EPS and in the bulleted text in a text box in one of the 'pages' text will be not as typed - jumps to the next line for some reason any. If I create a text box similar off the page I have no problem, and it lists as needed.

    The first image is as it should be, and the next image is how it makes its appearance. Any attempt to change seems futile.

    Any ideas please?

    ImgA.jpg

    ImgB.jpg

    Could there be a small invisible frame with applied at that time dress up there?

    Select all to see if it presents itself, or access the properties of frame and select this option to ignore the text wrapping to see if skin everywhere make these round lines.

    k

    I wonder if this background image a dressing applied with a setting, detect the edges so that the part of the image is kicking back your text.

  • Problem with the new text box - large size

    Hello

    I have a problem with InDesing and just can't understand why it's happening.

    When creating the text box (frame), I am selecting the text tool and want to drag a new text box, InDesing creates a new frame with size 1221, 058 x 1221, 058 mm (always, no matter what...). When I'm typing in it, the text is invisible, in the same way that it is out of reach of the size of the image (at the bottom right I see the Red Cross). It happenes even after hitting only one character and I can't make it visible (adjust to the right).

    Someone has any suggestions how to solve this problem?

    I will be grateful.

    System: Win 8.1

    InDesign worm. : output 2015.4 CC / 11.4.1.102 x 64 build

    Best regards

    Andrzej

    huge_textbox_InDesign.jpg

    First try: 101 troubleshooting: replace, or 'trash' your InDesign preferences

  • Problems with the HTML text and cutting!

    Hey everybody,

    This is my first post a lot! I have a very simple question but frustrating, I cut text in illustrator (object > slice > make), then to make this text in HTML (slice Options) text. Then I export my picture with other pictures behind this text using the 'Save for Web and devices' option to find that the "HTML" text has moved all art behind it!

    I have attached a picture of a very basic example of what is going on, as you can see all around this text has been moved, the text does not stay on top of the work behind it?

    screenshot.jpg

    I would appreciate any help on this problem, probably very easy to solve!

    Thank you very much!

    There is nothing "to"stay on top"- a slice is a slice and they are prepared automatically side by side. You can only assign a background color. I strongly suggest do you a little reading on HTML / CSS first. No offense, but you are using the wrong tool if you think that I could remotely anything like usable HTML code...

    Mylenium

  • Problem with the imported text from quark

    Hello world

    I imported the files of version 4 of quark offshore from a mac to Indesign cs4 on a windows PC. all is well apart from the text being a bit messed up, so I'm pretty happy with that. The problem is that when I drag or copy and paste into a new document images will move but new text will not work with the images.

    By this, I mean that when I try to type something above or nearby graphics graphics just disappear! You can drag on the image that they disappear, then when you drag them away them again reappear!

    Forms I hover over have a thin white border on them where the forms I created directly do not have this boarder.

    Any help you cold give me on this would be great!

    Thanks in advance!

    Sam

    A screenshot would be useful. Post the files would be even better.

    But a guess would be that the objects are actually online and text blocks have skin that are applied to them.

    Bob

  • I have a problem with the capture tool works not properly on Windows 8.

    Can I change to automatically let me start to select without clicking on New?

    Original title: snipping tool - work when I start it up, the new button has already been clicked but not at home

    Clarification:

    At work, my computer is Windows 7. At home, it is Windows 8. At work when I start the capture tool I have not hit any other button in order to start the selection of the area I want to Snip. The tool is already gray and my mouse is ready to score my selection.

    At home when I start the capture tool, I get the menu, click on 'New' and THEN I can start my selection - one additional click. It annoys me (I know it's small, but I cut a lot) so I was hoping there was a setting I could change how it starts.

    I know that's not exactly a new topic, but I found that I had the same problem.  I found that the cause of this problem actually comes from OneNote believe it or not.  If you have recently updated your Office Suite and now have the ability of OneNote, all you have to do is to open OneNote and configure.  Once you get it configured you can then select the options that you just press the Windows key + S to be able to cut out a screen shot and you can also set it to copy directly to the Clipboard, then there is no need to tap the new button more in the cutting tool.  Hope this makes sense and helps anyone having the same problems I had.

  • I have a problem with the Arabic text

    Hello

    I hope you can help?

    I do a letter that I have an Arabic translation of in a word document. When I copy and paste into Illustrator it changes the police (he says times new roman in the word doc, but the version of illustrator out times new Roman but seems completely different) and the right to the left direction from left to right. How can I fix it? I use CS4 which I think is the ME version (it is said in the Middle East on the side of the box) I know that the previous designer here managed to do this with the software, so I was hoping someone would have the answer?

    I do a letter that I have an Arabic translation of in a word document. When I copy and paste into Illustrator it changes the police (he says times new roman in the word doc, but the version of illustrator out times new Roman but seems completely different) and the right to the left direction from left to right. How can I fix it?

    Make sure that your language of the document is correctly set to Arabic in Word. Just typing Arabic and the document actuall in Arabic is two different things. Incompatibilities affect the Unicode beaches, resulting in errors of characters are copied to the Clipboard. In artificial intelligence, check alternatives on the range of text and glyphs palette as well as your glyph protection global pref.

    Mylenium

  • Problem with the 3D text

    Make the text a 3d object pushed back is fairly easy, but if I add filters for text, select it, and then try to make an object pushed the SELECTION, the text is rendered in 3d, but

    There is no hole between the letters O and P and. Is there anyway that I can cut in these letters? If not, if not, how can I make the text 3d with filters on them?

    Any help would be greatly appreciated, thanks

    See if this helps:

    http://forums.Adobe.com/message/4238532#4238532

  • Problems with the photoshop text tool

    I have photoshop CS6 and when I try to type using the text tool from the line that indicates where you write (the one that flashes) remains always at the beginning of the sentence that I write, so when I try to type in a comma or a point he puts it at the beginning of the line and not at the end. I don't know why it does. Thank you

    Have you tried Easter medium to check and change the setting there?

    In addition, on the type Panel, you have an option in its shortcut menu reset type. (icon at top right)

    You can also right click on the type tool icon in the options bar to reset.

  • Problems with the capture of HDC TM700

    Someone can help me. I have Windows 7, 64-bit

    CS5 Prem Pro system. Get a device of capture in offline mode when you try to

    captures from TM700 (PAL) HDC. Panasonic assures me that it will not work on a 64 bit system, but

    I have read other forums telling me that it is rubbish. Tried to set up the remote control, using the

    vice in standard type. When I'm Laura a panasonic support person what the devi

    type this to use was "Camcorder" I, (and all this time I thought it was a brick house!).

    What should I do now?

    Colin gave you a lot of good advice already, but here is a link for more information regarding ingestion of file-based cameras:

    "Import of assets from tapeless formats.

  • Problems with the drive 3 TB formatting directly in the Time Machine application

    I recently bought an external hard drive 3 TB WD Elements USB for Time Machine backups. Once I connected the drive for the first time, Time Machine asked if I would use it for backups. I chose the encrypted disk, the password and leave the reader to be prepared. This process lasted long enough (≍10 minutes), but in the end, Time Machine has complained that it is impossible to mount the newly prepared disk (see screenshot). However, if I manually create a HFS partition + encrypted in DiskUtility and then used this partition in Time Machine, everything works without a problem.

    I tried this in two different countries (the two El Capitan) Mac and the same thing happened.

    This is because you need to format the drive as a drive HFS + everything first. Time Machine formats not readers.

  • Problem with the display of alt text

    Hi guys, I have a strange problem here. my www.gogua.gr site cannot display alt text and I can not find the error, can you help me?

    Your website doesn't have a problem with the replacement text apart from the fact that you use innapropriately.  What I think you are looking for is 'ToolTip' that IE displays when you hover an image with alt text?  If so, that is to say wrongly uses the alt text and Firefox is correctly I think that, with the title attribute.  It isn't your site that may or may not display the text, this is the browser.

    With regard to the use of alt text to say 'click to enlarge', this isn't such a good idea.  The use of the text is to provide an alternative text for the image in case a viewer is not the images displayed, or uses a screen reader.  It should be used to describe the image.

    Martin

  • Problem with the language of Chinese/Japanese in Essbase

    Hello
    We have an obligation to indicate the name of the Alias of the members in different languages (German, Japanese, Chinese). I created an Application in Unicode Mode to handle this requirement. But when I keep the Table Alias Active as Japanese and Chinese, I do not see the text correctly I get some characters special, but in the German case, the values are displayed correctly.

    I even saw the application of Sample_U which is the default Unicode application, it if I change the active table alias of Japanese and Chinese text is displayed correctly.

    The application that I created and the Sample_U are on the same server Essbase.

    Hello
    Patrice,

    Make sure that you have installed, unicode fonts for example Arial Unicode MS and set the Regional service console font.

    http://www.Microsoft.com/typography/fonts/font.aspx?FMID=1081

    In addition, you can watch this thread: Re: problem with the unicode text file

    Concerning
    Robb Salzmann

  • problems with the text and rounded rectangles

    So I have some rounding of the rectangles in fireworks, then export as fxg, and import it into flash catalyst - but they lose the roundness of rectangles square become. Also have problems with the text as half displaying or doesn't appear do not at all.

    feature request

    -would be really cool to be able to change the paths in flash catalyst

    -Edit the code in code view

    see you soon

    brand

    Hi, the absence of a property of corner radius is a limitation of the FXG export command in Fireworks CS4. We work closely with the Fireworks team to improve interoperability FXG in CS5.

    Thank you for your comments and suggestions.

    -brian

    Team Flash Catalyst

Maybe you are looking for