-
1. Re: Script - Paste a TextFrame into a TextFrame
Muppet Mark Jan 26, 2012 11:08 AM (in response to natdeamer)Im not an ID server user but I thought it had NO C&P capabilities…
-
2. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 11:42 AM (in response to Muppet Mark)Yep, that is what I am finding. Just trying to find a way to do the same thing without copy and paste - Insert Text Frames one by one into a Text Frame
-
3. Re: Script - Paste a TextFrame into a TextFrame
Muppet Mark Jan 26, 2012 11:55 AM (in response to natdeamer)I have not tried myself… but a similar recent post had using library assets as a suggestion… Can you put the page item in a temporary library then use place asset?
-
4. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 12:02 PM (in response to Muppet Mark)I think that could work - Just got to learn how to do it... Will let you know
-
5. Re: Script - Paste a TextFrame into a TextFrame
Muppet Mark Jan 26, 2012 12:13 PM (in response to natdeamer)As I don't have id server I can't really say for sure. I did take a check over at…
http://www.jongware.com/idjshelp.html
and sure enough he's got id server helper files too… you will find invaluable
-
6. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 26, 2012 1:42 PM (in response to natdeamer)Hah -- that was quite difficult to pull off. You are correct in your observation that IDCS Server cannot use 'select', 'copy', and all other UI based commands, so you have to do it purely by manipulating the objects.
Unfortunately, all objects do have a 'move' method but ... it only can accept some page position and not an insertion point, which is what you need here. So there is no way to physically move an existing text frame into text (or, for that matter, a button, or a rectangle, line, ellipse or anything else).
But you can create a new object in-line:
mynewTextFrame = app.activeDocument.stories[0].insertionPoints[3].textFrames.add();
will create a new text frame between characters numbered 3 and 4 -- between the two letters "l" if the first word in the first story is "hello there!". Then you can move your existing text out of "someTextFrame" into the newly created frame, and copy as much other parameters as you need to it. Finally, you can delete the original frame (or perhaps move it out of the way onto the pasteboard, since you never know what you might need it for).
-
7. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 26, 2012 1:46 PM (in response to [Jongware])1 person found this helpful.. even better than copying properties one by one:
tf = app.activeDocument.stories[0].insertionPoints[3].textFrames.add();
tf.properties = app.selection[0].properties;
(This one works with a selection, but you can do the same for any valid object you can get a handle on.)
-
8. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 26, 2012 1:50 PM (in response to [Jongware])1 person found this helpful -
9. Re: Script - Paste a TextFrame into a TextFrame
Muppet Mark Jan 26, 2012 1:53 PM (in response to [Jongware])place asset said document or text… I took the general vagueness of the latter to mean any valid position within… gulp
-
10. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 1:57 PM (in response to Muppet Mark)Jongware and Muppet Mark - Thank you . I think I should be able to do this now!
Will update shortly!
-
11. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 2:25 PM (in response to natdeamer)So it got my text boxes in... But I lost all the font properties (color, size, font, alignment).
var masterTextFrame = myDocument.pageItems.item("masterTextFrame");
var textFrame1 = myDocument.pageItems.item("textFrame1");
var textFrame2 = myDocument.pageItems.item("textFrame2");
var newTextFrame = masterTextFrame.insertionPoints[0].textFrames.add();
newTextFrame.properties = textFrame1.properties
var newTextFrame2 = masterTextFrame.insertionPoints[0].textFrames.add();
newTextFrame2.properties = textFrame2.properties.
I also lost the 'GraphicFrame' inside the TextFrame.... - but haven't looked into this yet.
-
12. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 26, 2012 2:36 PM (in response to natdeamer)Uh, well, my test worked with the default settings of a new text frame, and it seemed the properties of the frame itself got copied.
If you are loosing your text settings, you can always use "move" to move the text out of the original into the new frame -- and you won't be needing the old badly formatted text anyway, so perhaps you should delete that first.
As for the graphics: are those inline objects? Maybe you have to move the elements one by one ...
If only one could use "move" with an insertion point as a target! File a feature request? CS6 is coming soon.
-
13. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 26, 2012 2:40 PM (in response to [Jongware])1 person found this helpfulYeah this works for me, duplicating the entire contents of the original frame takes inlines along:
tf = app.activeDocument.stories[0].insertionPoints[3].textFrames.add();
tf.properties = app.selection[0].properties;
tf.texts[0].remove();
app.selection[0].texts[0].duplicate (LocationOptions.AT_BEGINNING, tf.texts[0]);
-
14. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 2:54 PM (in response to [Jongware])Thanks - this worked for the text (1,2,3) but not for the Graphics.
The graphics were pasted into the TextFrames. Maybe I can use move to get the contents of a textframe (graphic) and move to the new text frame?
-
15. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 26, 2012 3:05 PM (in response to natdeamer) -
16. Re: Script - Paste a TextFrame into a TextFrame
கற்பனை (Imagine) Jan 26, 2012 11:34 PM (in response to natdeamer)I think snap shot structure almost look like a table. You have use the table instread of TextFrames, So it makes easy to your works.
-
17. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 27, 2012 2:56 AM (in response to natdeamer)Fixed the TextFrames to fix the vertical alignment...
var newTextFrame6 = masterTextFrame.insertionPoints[0].textFrames.add();
newTextFrame6.properties = tf6.properties;
newTextFrame6.texts[0].remove();
tf6.texts[0].duplicate(LocationOptions.UNKNOWN, newTextFrame6.texts[0]);
newTextFrame6.textFramePreferences.properties = tf6.textFramePreferences.properties;
Now just need to get these graphics inside the other thext frames......
-
18. Re: Script - Paste a TextFrame into a TextFrame
[Jongware] Jan 27, 2012 3:12 AM (in response to natdeamer)Nat, it worked for me when testing because my test graphics were pasted in-line in the source text frame, and so they move along with the rest of the text. It doesn't work if they are pasted "on top" of the text frame, they have to be inside.
-
19. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 27, 2012 3:25 AM (in response to [Jongware])The problem was this line:
newTextFrame.texts[0].remove(); - It would throw an exception because there is no texts inside my TextFrames with the Image. Once I removed that, it worked
I will upload my code shortly -
20. Re: Script - Paste a TextFrame into a TextFrame
natdeamer Jan 27, 2012 5:52 AM (in response to natdeamer)1 person found this helpfulfunction moveIntoMasterTextFrame(masterTextFrame, arr) {
if(masterTextFrame.isValid){
for (var i = 0; i< arr.length; i++) {
if(iconTextFrame.isValid) {
var textFrame = arr[i];
var newTextFrame = masterTextFrame.insertionPoints[0].textFrames.add();
newTextFrame.properties = textFrame.properties;
if(newTextFrame.texts.length > 0){
newTextFrame.texts[0].remove();
}
textFrame.texts[0].duplicate(LocationOptions.AT_BEGINNING, newTextFrame.texts[0]);
newTextFrame.textFramePreferences.properties = textFrame.textFramePreferences.properties;
}
}
}
}
masterTextFrame - the frame we are moving into.
arr - an array of text frames.