Skip to main content
Inspiring
March 23, 2026
Question

Deleting text from text frame only removes visible content, not overflow text

  • March 23, 2026
  • 3 replies
  • 62 views

Hello All,

I am trying to delete text from a text frame using a custom function. However, the function only deletes the visible text inside the frame. There is still additional text present as overflow (indicated by the “+” icon at the bottom right of the text frame).

It seems like my code is only targeting the visible portion and not the entire content of the text frame.

Question:
How can I delete all the text from the text frame, including the overflow text?

What I’ve tried:
I have written a function to clear the text, but it only affects the visible content.

ErrorCode DeleteText(const UIDRef &textFrameUIDRef)
{
ErrorCode status = kFailure;
do{
IDataBase* iDataBase = textFrameUIDRef.GetDataBase();
if(!iDataBase)
break;

InterfacePtr<IGraphicFrameData> frame(textFrameUIDRef, UseDefaultIID());
if(!frame)
break;

if(frame->GetTextContentUID() == kInvalidUID)
break;

InterfacePtr<IMultiColumnTextFrame> mcFrame(iDataBase, frame->GetTextContentUID(), UseDefaultIID());
if(!mcFrame)
break;

InterfacePtr<ITextModel> iTextModel(iDataBase, mcFrame->GetTextModelUID(), UseDefaultIID());
if(!iTextModel)
break;
TextIndex start = mcFrame->TextStart();
int32 length = mcFrame->TextSpan() - 1;;

if(length > 0)
iTextModel->Delete(start,length);

// UID id = (GetNextThreadedTextFrameUID(textFrameUIDRef)).Get();
}while(false);
return status;
}

Thank You

Chetan

3 replies

Legend
March 25, 2026

Try deleting only the primary thread length, the text model has separate threads for nested things. Table cells, endnotes or worse.

Peter Kahrel
Community Expert
Community Expert
March 24, 2026

You can delete the text frame’s parent story. In JS that would be

myFrame.parentStory.remove();

or, if that causes a problem (it did at some stage, but I can’t remember when or which version):

myFrame.parentStory.contents = ‘’;

 

Community Expert
March 23, 2026

ITextModel has a method called TotalLength()
ITextModelCmds has a method DeleteCmd()

These two should be helpful for your usecase

-Manan
Chetan SAuthor
Inspiring
March 24, 2026

Thank you, Manan, for your help. I tried getting the total length using iTextModel->TotalLength(),

However, this is causing a crash. It seems that TotalLength() might be returning an extra count, because the code works when I pass a slightly smaller value.

Could you please help me understand what I might be doing wrong?”

int32 length = iTextModel->TotalLength() - 1;
iTextModel->Delete(0,length);

 

Community Expert
March 24, 2026

You can’t delete the whole content of a frame, there should be one character in the story which should not be deleted. If you notice when you create a frame there is character shown by a # symbol, if you switch on the show hidden characters. So I suppose if you delete length - 2 it should work.

-Manan