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

Copy contents of one textframe to another

New Here ,
Mar 23, 2012 Mar 23, 2012

I have a 2 documents, I want to copy the fully formatted content from one textframe on to another textframe in another document.

I have both textframe objects.

I have tried creating a temp textframe and moving it but the frames in question have XML Tags attached, which get coppied in the document when the temp frame is created.

any thoughts?

cheers

jsx

TOPICS
Scripting
6.4K
Translate
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

correct answers 1 Correct answer

Guru , Mar 26, 2012 Mar 26, 2012

Hi D Jon Simcox

Why don't you use


parentSourceStory.duplicate(LocationOptions.after, destTextFrame[0].insertionPoints[0] );

Without using "paragraphs.everyItem()" ?

Don't see that its needed.

Translate
Community Expert ,
Mar 23, 2012 Mar 23, 2012

If you want to copy text contents, you don't have to mess around with its containing frame. Use myTextFrame.texts[0] and the Text Duplicate or Move method (http://jongware.mit.edu/idcsjs5.5/pc_Text.html).

Don't worry about the plural and index number of "texts[0]" -- I believe this is more of a side-effect of the programming model (and it has been left that way to prevent having to code multiple workarounds for such a minor issue), rather than that anticipating that somewhere in the future it's going to be possible to have "more than one Text" per frame.

Translate
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
Guru ,
Mar 25, 2012 Mar 25, 2012

Just to expand on Jongwares answer with a of practical example.

To copy selected text of  to a different text frame or to copy entire contents of the text frame were the cursor is see bellow script.

Look at the reference that Jongware provided for other location options

myDoc = app.activeDocument;

myText=app.selection[0]; // Copies selected text DELETE THE LINE BELOW IF YOU WANT TO DO THIS!!

myText=app.selection[0].parentTextFrames[0].texts[0]; // Copies entire text frame contents.

myPage = myDoc.pages.add();

myTextFrame = myPage.textFrames.add();

myTextFrame.geometricBounds = [8, 8, 800, 200];

// Copies to new text frame (to move to new text frame use the  move instead of duplicated i.e. myText.move(LocationOptions.AFTER,myTextFrame.insertionPoints[0]) ;  

myCopy =myText.duplicate(LocationOptions.AFTER,myTextFrame.insertionPoints[0]) ;

Translate
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 Beginner ,
Jul 18, 2017 Jul 18, 2017
LATEST

past ? : end of last page & end of a paragraph

Translate
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
Guru ,
Mar 25, 2012 Mar 25, 2012

If you have an old version of indesign (no idea which) you might have to go with this approach.

http://www.mombu.com/computer_design/indesign/t-copy-paragraphs-from-one-textframe-to-another-120686...

Translate
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 ,
Mar 26, 2012 Mar 26, 2012

Hi Both,

Thanks for the input. I ended up traversing up to the top parentStory and then copying the paragraphs, as the other methods did not seem to work to well with linked text boxes.

here is what I have - which seems to work for me.

Assuming sourceTextFrame and destTextFrame are the textFrames you want to copy the content from......

                    var theSourceFrame = sourceTextFrame[0];

                    var parentSourceStory = sourceTextFrame[0].parentStory;

 

                    parentSourceStory.paragraphs.everyItem().duplicate(LocationOptions.after, destTextFrame[0].insertionPoints[0] );

thanks again

Translate
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
Guru ,
Mar 26, 2012 Mar 26, 2012

Hi D Jon Simcox

Why don't you use


parentSourceStory.duplicate(LocationOptions.after, destTextFrame[0].insertionPoints[0] );

Without using "paragraphs.everyItem()" ?

Don't see that its needed.

Translate
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 ,
Mar 26, 2012 Mar 26, 2012

Trevor,

you are absolutely right - thanks

Translate
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