Copy blocks of text between documents

I have two documents which have the same number of pages. I want to write a script to copy blocks of text on each page of the document source to the corresponding page in the target document. There is usually only a single block of text on each page, and I want it placed exactly the same in the target as the source. I tried the following:

for (var i = 0; i < fromDoc.pages.length; i ++) {}

for (var j = 0; j < fromDoc.pages [i].textFrames.length; j ++) {}

var fromTextFrame = fromDoc.pages [i] .textFrames [j];

App.Select (fromTextFrame);

App.Copy ();

toPage var = toDoc.pages [i];

App.Select (toPage);

App.Paste ();

}

}

It gives me an error on the statement of app.copy: "Cannot copy/cut because of invalid selection."

Can someone help me with the right code? That the ks!

Sorry - it's a bug in the forum software that is sometimes

submitted by email do not appear. What I said is:

You should avoid the use of copy(), paste() etc. - There is almost always a

best way to do things.

In this case, see the duplicate of a textFrame method:

TextFrame.duplicate (for: varies by: table of unit of measure (number or))

String)): PageItem

Adobe InDesign CS6 (8,0) Object Model

Duplicates the TextFrame to the location specified or offset.

of: Data Type: varies

The location of the new TextFrame, in coordinates specified in the

format. Can accept: table of 2 units, spread, Page or layer.

(Optional)

by: Data Type: table of unit of measure (number or string)

Amount to compensate for the new original TextFrame

TextFrame position. (Optional)

You can see that the setting 'to' duplicate() accepts various

things, which seems to be what you are looking for: page.

So if you set myPage to a page in a second document, likely to be you

will find that it has been reproduced on this page:

myTextFrame.duplicate (myPage)

Try and see how the text block lands facing upward.

If this isn't in the right place, I suggest to copy the

the source for the new textFrame textFrame geometricBounds (he can be)

have other ways to do it). Just ensure that the origin of the rule and

units of measure in the two documents are the same.

HTH,

Ariel

Tags: InDesign

Similar Questions

  • [CS 5.5] [JS] copy a graphic page between documents element

    Hi, I'm still learning script and am struggling with what is probably a simple problem to someone more knowledgeable. The task is to copy the text & chart of a few pages of a document from one to the other based on a similar model. The block of text and graphic blocks are named. I was able to get the part of the text, but I'm stuck on how to address them - stick in a graphic block.

    At this point, I got the graph to copy, but it does not quite work because the duplicate method allows only a table of 2 units, fattening, Page or layer target and source document positions are slightly different, and copy the chart only leaves out necessary style of the frame. I really want to stick it in the page element, but differs from the method for duplication of text. Tips to approach this? Should I instead to select the graphic and paste it into the new document? How I would achieve the equivalent of sticking in there?

    A snippet of my code so far:

    var docPages = docRef.pages.everyItem().getElements();
    var cemwpsP1 = 3;
    var newWPS = createWPS(templatePath, wpsTemplateName, wpsFileName, wpsSaveFolder);
    var graphsRE = new RegExp (/graph/i);
    var textsRE = new RegExp (/body|chart/i);
    
    var srcPage = docPages[cemwpsP1];
    var wpsPage = newWPS.pages[0];
    for (i = srcPage.pageItems.length -1; i >=0; i--) {
     var pi = srcPage.pageItems[i];
     if ( pi.name.match(textsRE) ) {
     // copy the text element
     pi.texts[0].duplicate(LocationOptions.AT_BEGINNING, wpsPage.pageItems.itemByName(pi.name)); 
     }
     if ( pi.name.match(graphsRE) ) {
     // it's a graphic element
     // still stumped here! only copies to to the same coordinates on the new page...
     pi.allGraphics.duplicate(wpsPage);
     }
    }
    
    

    OK, if anyone is interested, I solved it by copying the graphic dimensions of empty graphic images of the model, and then nuking replacing them with a chart double. This technique works for all elements of the page are appointed in the same way on the source and target pages.

    // step through page items on each page, checking item name matches as set in graphsRE & textsRE above & moving over to the new pages
    var srcPage = docPages[cemwpsP1];
    var wpsPage = newWPS.pages[0];
    for (i = srcPage.pageItems.length -1; i >=0; i--) {
        var pi = srcPage.pageItems[i];
        if ( pi.name.match(textsRE) ) {
            // it's a textual element, either ta.wpsFrameName or ta.wpsChartFrameName
            pi.texts[0].duplicate(LocationOptions.AT_BEGINNING, wpsPage.pageItems.itemByName(pi.name));
        }
        if ( pi.name.match(graphsRE) ) {
            // it's a graphic element, and should only contain one graphic
            // since ID doesn't allow copying into frames (or I never found how)
            // get its matching info from the wps template
            wpsBounds = wpsPage.pageItems.itemByName(pi.name).geometricBounds;
            wpsObjStyle = wpsPage.pageItems.itemByName(pi.name).appliedObjectStyle;
            // kill the original & duplicate the graphic to wps
            wpsPage.pageItems.itemByName(pi.name).remove();
            pi.allGraphics[0].duplicate(wpsPage);
            // get a reference to the newly placed graphic; it'll be the only nameless one, as they are all named on the template
            for (g = wpsPage.pageItems.length -1; g >=0; g--) {
                if ( wpsPage.pageItems[g].name == "" ) {
                    gfc = wpsPage.pageItems[g];
                }
            }
            // name, size and style
            gfc.name = pi.name;
            gfc.geometricBounds = wpsBounds;
            gfc.appliedObjectStyle = wpsObjStyle;
        }
    
  • regexp_substr: retrieve a block of text between delimiters

    Hello

    regexp_substr is very powerful, but not so easy to understand. I'll try to do my best, but I need your help.

    My question is this: I have a multiline text, stored in a database field. The text is structured as a "windows.ini" file: there are sections in square brackets and the lines of text in the section.

    I want to retrieve all of the text in a given section, and I think it's possible using regexp_substr.

    Here is the text of the field (in bold the part I want back):

    ---

    [ARTICLE 1]

    AAA = 123

    BBB = 456

    CCC = 789

    [ARTICLE 2]

    DDD = 987

    EEE = 654

    ---

    In other words, is there a way to retrieve the text between [ARTICLE 1] and [ARTICLE 2]?

    Thank you in advance.

    Concerning

    Select

    regexp_substr (txt, ' [de] [^] +', 1, level * 2) s

    t

    connect by level<= regexp_count(txt,="">

  • Copy and paste into a Word document loses its format (chips, colored tex, etc.) where Firefox is open. When I close Firefox it's fine again. I'm not talking about copying and pasting text between MS Word and Firefox. It is in MS Word itself.

    Firefox 11.0
    MS Word 2003 Basic Edition SP3

    Can be caused by the click of Skype to the extension of the appeal.

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance/themes).

  • CS5 - most effective way to wire and independent streams of two blocks of text in the same document?

    Greetings...

    I am responsible for creating a 100-page instructor guide and I looking for a little guidance in the use of independent text blocks that thread the length of the document.  The idea behind the use of two columns, is that the first column (left) must be used for the notes 'instructor-only', advice, etc..  The second column (right) should be used for the text of the student guide.  Two columns (or blocks of text) would need to move independently of each other.  In other words, when the left column is filled with text placed on the page, the flow of additional text in the left column on page two, left column on page three, etc.  Same thing applies to the right column.  There is no link or thread of the text between the two columns on the same page.

    I tried to reproduce this in a two-column table format, however, the table row height is limited and overset text will not continue the table in the block of text on the next page.

    Thank you in advance for your help!

    Set up master page text frames.

    If you use facing pages, put on the student to the student and executive trainer instructor on master pages.

    Be very careful when your document is redéroule however. Take a look at this discussion, we had recently on the subject:

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

    HTH,

    Substances

  • I use the current trial of Acrobat DC version. I opened a PDF I created in Corel Draw by publication in PDF format. I tried to copy and paste text from it to a Word 2007 document. The copy option was available, but when I went to the document and ch

    I use the current trial of Acrobat DC version. I opened a PDF I created in Corel Draw by publication in PDF format. I tried to copy and paste text from it to a Word 2007 document. The copy option was available, but when I went to the document and chose paste, it was nothing. I then tried the same thing but sticking in a document of Corel. The same problem. It seems that the text has been copied, but I'm unable to paste it into another program. Is this real?

    Is it permanently available text? (Can highlight you)?

    This seems a strange way of working well - why not copied from the draw to Word?

  • Copy block of pasted text split over different video tracks remain linked

    I tried to find a way to fade and fade out text and came up with the following solution:

    It works:

    --Commencer start with an empty project, add a video clip (video 1 track)

    -Add a block of text by default to the video 2 track, accept the text by default, simply apply FadeInByLine animation

    -Add a block of text by default to the video 3 track, accept the text by default, simply apply the animation FadeOutByLine

    -Re-position the block of text to the video 3 track so he starts where the block of text in video track 2 ends

    Play your movie, the text fades in and out as it should. So, what happens if you do not want to have the text in the Center and you want it to have a different color or font, or style?

    Try this and this is where things get weird:

    --Commencer start with an empty project, add a video clip (video 1 track)

    -Add a block of text by default to the video 2 track and change the font color, also reposition the text somewhere on the lower left corner of the screen, then apply the animation FadeInByLine

    -Now, you don't want to repeat throughout all these stages of formatting, so duplicate the text block by copy paste (it will be pasted on the same track, both video 2 track)

    -Now drag the duplicated text frame the video 2 track to the video 3 track

    -Re-position the block of text to the video 3 track so he starts where the block of text in video track 2 ends

    -Apply the FadeOutByLine animation on the block of text on the video track 3

    Read your movie and you'll see that two blocks of text are the FadeOutByLine animation. If you change the animation of a block style, the same style will apply to the other block. They are still linked to the each other.

    Suggestions anyone?

    janionder

    For now I guess you have to first items 11, 12 or 13 on Windows 7, 8 or 8.1 64bits.

    You forgot a fundamental principle of the titration module. You cannot copy a title, change the copy without your changes to the copy in the original title.

    What you need to do, this is the original in the assets of the project right click and select duplicate. Duplicate will have a different name from the original... Drag the duplicate to the timeline

    and make your changes without simultaneously changing the text in the original to match your changes in the copy.

    Why you not only add a Fade In and Fade Out for the title, rather than text animators applying the way you have?

    With the closed titration module, right-click on the title on the timeline, select melted, then fade in video. Then, right click the title again, this time in video output.

    You will notice that the clip of two sets of white dots on the orange band that goes by the title, a set at the beginning of the title, and another series at the end of the title. Them are opacity keyframes. You can adjust these 'points' with the mouse cursor to customize your fades.

    If you do not use the double active project to avoid the titles of all ending up with the same changes, then just rename a title in the active project.

    Please consult the bulletin and review, and then let us know if none of this works for you. For any question or need for clarification, please let me know.

    Thank you.

    RTA

  • Heights of game for all the blocks of text in a document

    Looking to do something seemingly simple. I want all the blocks of text in my document to the same height.

    Here's where I am.

    app.activeDocument.textFrames.everyItem () .height = "2.3195 in."

    Note: I work in InDesign CS5.

    Any help on where to go from here would be greatly appreciated.

    Or, in the CS6 and later*:

    var NEW_HEIGHT = '2.3195 in';
    
    // MULTIPLE RESIZE() IN ONE STEP
    // =============================
    app.activeDocument.textFrames.everyItem().resize(
    
        // Target bounding box(es) -- Use OUTER_STROKE_BOUNDS if needed
        // ---
        [CoordinateSpaces.INNER_COORDINATES, BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS],
    
        // Reference point -- Here resize is performed relative to the top edge
        // ---
        AnchorPoint.TOP_CENTER_ANCHOR,
    
        // Absolute replacement
        // ---
        ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
    
        // [width, height] in points
        // ---
        [ResizeConstraints.KEEP_CURRENT_VALUE, +UnitValue(NEW_HEIGHT).as('pt')]
        );
    

    * Can operate CS5. x too, but I think remember that CS4 has a bug where resize() is a plural specifier whose receptors belong to several blocks spread.

    @+

    Marc

  • I need to select all the blocks of text in a document and align text blocks in the back pages left frame margin and the text in the pages front to the right margin.

    Hello

    Am new to Java script.

    Can someone help me out here, I need to select all the blocks of text in a document and align text blocks in the pages back to the left margin frames and text in pages recto at the right margin.

    Thank you
    Harish

    Hi Harish,

    Try this.

    var doc =app.activeDocument,
        _pages = doc.pages;
    doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    for(var i =0;i<_pages.length;i++)
    {
            txfms = _pages[i].textFrames.everyItem().getElements();
            for(var j =0;j
    

    Kind regards

    Cognet

  • How to remove the unwanted border around blocks of text copied and pasted

    In creating a glossary, we copied and pasted text blocks of some later entries in the glossary. Now we're getting borders around these blocks of text copied - we do not want. Original text blocks show no borders.

    How get rid of these borders?

    Thank you in advance, David Allen

    Select the images and the race set to 0 and then deselect everything and make sure that you do not have a default line for new executives.

  • Can't add placeholder text data merge for all blocks of text on the document

    I'm trying to put together a script that loops if all pages in an indesign file, search all text frames label caption1, caption2, caption3... (whenever you get to a new page, the number of text images label starts again from 1) and add a placeholder in the text data fusion: caption1, caption2, caption3... but this time, when you get to a new page the number continues to go... caption4, caption5 and so on.

    Page 1 - image text = caption1 = tag > data merge placeholder = < < caption1 > >

    Page 1 - image text = caption2 = tag > data merge placeholder = < < caption2 > >

    Page 1 - image text = caption3 = tag > data merge placeholder = < < caption3 > >

    page 2 - text = caption1 = image tag > data merge placeholder = < < caption4 > >

    page 2 - image text = caption2 = tag > data merge placeholder = < < caption5 > >

    Currently, the script is adding placeholder text merge data only for the two text frames first (out of 6) on a page (about 8 pages) and just the first image of text on the page two (out of 3)

    Any help will be greatly appreciated

    Here's the script:

    myDocument var = app.activeDocument;

    -SOURCE DATA CALLS FUSION

    main();

    main() {} function

    myDataSource var = File.openDialog ("Please select a datamerge source", "text files: * .txt");

    If (myDataSource! = null) {}

    myDocument.dataMergeProperties.selectDataSource (myDataSource);

    myDocument.dataMergeProperties.dataMergePreferences.recordsPerPage = RecordsPerPage.MULTIPLE_RECORD;

    }

    }

    -MERGE OF DATA FIELD

    function get_field (captionString, myDocument) {}

    fields var = myDocument.dataMergeProperties.dataMergeFields;

    for (var f = 0, l = fields.length; e < l; f ++) {}

    If (fields [f] .fieldName == captionString) {}

    Returns the fields [f];

    }

    }

    Alert ("error: did not find all the fields with the name" + field_name);

    }

    THE TEXT - ADD PLACEHOLDER DATA MERGE

    var countFrames = 1;

    for (i = 0; i < myDocument.pages.length; i ++) {/ / TOTAL NUMBER OF PAGES in the DOCUMENT}

    var capPerPage = 1;

    for (x = 0; x < myDocument.pages [i].textFrames.length; x ++) {//COUNT TEXT TOTAL IMAGES PER PAGE

    If (myDocument.pages [i] .textFrames [x] .label < 0) {}

    Alert ('can not find any image caption');

    } ElseIf (.textFrames [x] myDocument.pages [i] .label == 'caption' + capPerPage) {//IF IT IS A TEXT LABEL of IMAGE 'caption1' EXECUTE

    var captionString = "caption" + countFrames;

    var myTextFrame = myDocument.pages [i] .textFrames [x];

    var myDataMergeProperties = myDocument.dataMergeProperties;

    var myTextFrame.parentStory = monarticle;

    var myStoryOffset = myTextFrame.parentStory.insertionPoints [-1];

    var myNamePlaceHolder = myDocument.dataMergeTextPlaceholders.add (monarticle, myStoryOffset, get_field (captionString, myDocument)); ADD DATA FUSION TEXT HOLDER TO THE TEXT BLOCK

    countFrames ++; INCREASE THE NUMBER TO ADD DATA FUSION TEXT PLACEHOLDER FOR THE NEXT BLOCK OF TEXT

    capPerPage ++;

    }

    }

    }

    Hello

    To verify this change (replace for...) loop)

    var countFrames= 0, currLabel, capPerPage;
    
    for (i=0; i
    

    Notice countFrames starts at 0.

    Jarek

  • Conditional text - copy 'only' the text/object visible in another indesign document

    Is it possible to copy the visible text on the indesign document in another document indesign without having to copy the hidden text and the conditons as well? Or... what I can remove hidden text in new documents in an Exchange with affecting the text visible?

    I have to think on this for a while... then I ask the great gurus of spiritual guidance and time to figure it out myself.

    Tack sa mycket.

    It is scriptable. If nobody answers here, ask in the InDesign Scripting forum.

  • How place a document that requires a block of text to span several pages?

    I'm working on an information folder and have a word doc that contains 3 or 4 pages of text I want to merge my flyer. No matter what I try, when the use of Place (command-B), I can't get the text block resulting automatically create pages as needed. I checked n the option of 'Smart Text reflow' preferences and unchecked option "limit of main text Frames". Deparation, I even created an empty text block, turned on the Auto for this image and copied sizing the command + V) text in, but he did not better. I would prefer not to have to divide the text into chunnks and put it in blocks of text separated on each subsequent page. Any ideas?

    I use CS6 on a new MacBook Pro running OS X Lion mountain with 16 GB of RAM.

    When you place the text, hold down the SHIFT key when you click on the page.

    Bob

  • Copy the block of text in most of the pages

    Using CS4. I am designing a photo book and want to add a caption below photos on most of the pages.

    How to copy a block of text to most of the pages of the book, positioned at the same place on each page?

    Looks a very basic thing to want to do, but impossible to find some sort of obvious way to do.

    Must have something to do with master pages.

    Master page would certainly be a way to do it. Put the rframe on the master, then substitute ([Ctrl on windows] Cmd + Shift-click on the page docuent to release a Master object) to enter text or remove images or place text in the frame (without replacement) from an external file.

  • Use Applescript to copy layer objects between documents

    I'm currently following script with AppleScript:

    1. the user selects the files of reference and target

    2. open reference file

    3. Select and copy objects on a specific layer to the Clipboard

    4. Paste the contents of the Clipboard in a specific layer in the target file

    The dictionary of InDesign CS3 has a copy command, but I encounter an error all sense, I try to use it

    copy v : copy the selection in the document window active the Clipboard.

    My script up to now:

    - prompt the user for the reference and the target files

    the value the reference_file to Choose file with guest ' select the InDesign of the reference file: " without invisible

    -the target_file choose file with guest the value "select the target file:

    say application «Adobe InDesign CS3»

    activate

    set myLayer to "Layer 1"

    Open reference_file

    say active document

    set reference_layer to reference object of ()layer myLayer( )

    choose all point page of reference_layer

    copy selection

    -narrow reference_file save no.

    end tell

    end tell

    ERROR MESSAGE:

    "Adobe InDesign CS3 was a mistake: selection in the active document does not include the message copy."

    Anyone know how to use the verb correctly copy?

    Hello:

    Try to use

    copy

    in itself, without following parameter. In my scripts, I tell the App to do, not the document or page.

    HTH,

    EGR

Maybe you are looking for