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

Clipping a table in a textframe with pasteInto

Contributor ,
Nov 10, 2024 Nov 10, 2024

Copy link to clipboard

Copied

Hi,
 
My use case is to be able to take a table which is inside a text frame and "pasteInto" the same text frame, so that the table clipped to the text frame dimensions.
 
Here's the code snippets I have got so far:
 
// Create the table
var myTable = textFrame.insertionPoints[-1].tables.add(...)
 
// Generic code to check the text frame in which the table is located
var topTextFrame = undefined
for (var i = 0; i < g.doc.textFrames.length; i++) {
    var thisTextFrame = g.doc.textFrames[i];
    // Check if the text frame's story contains the nestedTextFrame as an anchored object
    if (thisTextFrame.textFrames.itemByID(textFrame.id).isValid) {
        topTextFrame = thisTextFrame;
        break;
    }
}
 
// If we located the topTextFrame, "paste Into" the table back into the same topTextFrame 
if (topTextFrame) {
    $.writeln("Top text frame found.");
    app.select(textFrame);
    app.copy();
    app.select(NothingEnum.NOTHING);
    app.select(topTextFrame);
    app.pasteInto();    // At this point, the top level text frame is getting convered to a graphic frame
}
 
Q1. Is this the right way to do pasteInto for my use case?
Q2. I observe on line app.pasteInto that the text frame is getting converted to a graphics frame. Is this expected and can we have a custom behavior to retain the topTextFrame as a text frame?
Q3. What would be a generic code to identify the graphic frame id and the new table id (since the original myTable is already removed as part of pasteInto)
 
Thanks,
 
 
TOPICS
How to , Scripting

Views

633

Translate

Translate

Report

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

Community Expert , Nov 11, 2024 Nov 11, 2024

@asaxena

 

In order to achieve what I think you want to achieve - you would've to pasteinto your table into a Rectangle then Anchor / InLine your Rectangle into another TextFrame.

 

Votes

Translate

Translate
Community Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

take a table which is inside a text frame and "pasteInto" the same text frame, so that the table clipped to the text frame dimensions.

 

This isn't very clear. Please explain in more detail, with a screenshot of the before and after situations of what you want to achieve.

 

As to pasteInto, in scripting you'd use duplicate() or move(), thay're more reliable, and you can maintain references. Much more robust than copying and pasting.

Votes

Translate

Translate

Report

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
Contributor ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

Sure. My situation is like so:

I have a blue swatch table which is inside a red swatch text frame:

asaxena_0-1731317327580.png

The Layers show up like so:

 

asaxena_2-1731317532558.png

 

What I am after, is to start from the above layout, and then clip the table to the bounds of the text frame like so while retaining the blue as the table Text Frame and the Red as the Text Frame.

asaxena_1-1731317383098.png

Unfortunately the Layer window reports that the blue frame is now "graphics frame" instead of the Text Frame

asaxena_3-1731317626923.png

 

Thanks

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

You can't clip a table like that. The only way to achieve that is what InDesign already does for you: convert the frame with the table to a graphic.

 

You could cover the extending part of the table with a text frame and give it the Paper fill and group the whole thing, that's the closest you'll get I think.

Votes

Translate

Translate

Report

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
Contributor ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

I tried those steps in InDesign and it works the exact same was the script does. I am purusing this approach based on the discussion at Solved: Re: Clipping of InDesign table - Adobe Community - 14920622

 

Might I have missed something?

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

That solution doesn't work for me.

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

@asaxena

 

You mean red frame is a graphic frame?

 

If you've a TextFrame - you can only Anchor / InLine other objects - as characters. 

 

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

@asaxena

 

In order to achieve what I think you want to achieve - you would've to pasteinto your table into a Rectangle then Anchor / InLine your Rectangle into another TextFrame.

 

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

@asaxena 

 

RobertatIDTasker_0-1731326527597.png

 

Votes

Translate

Translate

Report

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
Contributor ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

Ok. I tried "pasteInto" of my table into the Rectangle. The (erstwhile) Rectangle is now showing up as a <graphic frame>. How do I get this into the Rectangle as a Text Frame?

 

asaxena_0-1731333372674.png

 

Votes

Translate

Translate

Report

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 Expert ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

quote

Ok. I tried "pasteInto" of my table into the Rectangle. The (erstwhile) Rectangle is now showing up as a <graphic frame>. How do I get this into the Rectangle as a Text Frame?

 

By @asaxena

 

As I said before - now, you need to Anchor / InLine this Rectangle in another TextFrame. 

 

But what exactly is your end goal? 

 

Votes

Translate

Translate

Report

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
Contributor ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

quote
quote

Ok. I tried "pasteInto" of my table into the Rectangle. The (erstwhile) Rectangle is now showing up as a <graphic frame>. How do I get this into the Rectangle as a Text Frame?

 

By @asaxena

 

As I said before - now, you need to Anchor / InLine this Rectangle in another TextFrame. 

 

But what exactly is your end goal? 

 


By @Robert at ID-Tasker

 

The use case is that only some of the (potentially numerous) columns of (potentially numerous) tables need to be be visible for publication. However, at present, all the columns of the tables are being paginated by our plugin. So, we need to be able to provide a way for the user to be able to hide/clip the unrequired columns on the document for purposes of publishing

Votes

Translate

Translate

Report

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
Contributor ,
Nov 11, 2024 Nov 11, 2024

Copy link to clipboard

Copied

No, matter what I try, I land up in having the Rectangle (after pasteInto of the table) as a graphic frame inline in the Text Frame. I am using the blue marker (with Shift) to drag the Rectange as inline anchored object in the Text Frame. Please suggest what I might be missing.

 

asaxena_0-1731392160061.png

 

Thanks

Votes

Translate

Translate

Report

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 Expert ,
Nov 12, 2024 Nov 12, 2024

Copy link to clipboard

Copied

You cannot clip a table and keep it as a text object. It's just impossible. As stated earlier (and in the link you provided) the only two ways are:

 

1. Convert to a graphic

2. Mask the parts you want to make invisible.

 

Note that the answer marked as correct in the other post claims only that part of the table will be visible after the paste. It doesn't say that the table remains a text object.

 

Masking the parts that stick out of the frame is very simple, by the way: you just place text frames (or rectangles (paper fill, no stroke) on top of the parts you want to hide. Easy to script too.

Votes

Translate

Translate

Report

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 Expert ,
Nov 12, 2024 Nov 12, 2024

Copy link to clipboard

Copied

LATEST
quote

No, matter what I try, I land up in having the Rectangle (after pasteInto of the table) as a graphic frame inline in the Text Frame. I am using the blue marker (with Shift) to drag the Rectange as inline anchored object in the Text Frame. Please suggest what I might be missing.

 

asaxena_0-1731392160061.png

 

Thanks


By @asaxena

 

And now resize your "graphic frame" - use it as a "clipping frame". 

 

Votes

Translate

Translate

Report

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