Skip to main content
Inspiring
Mar 23, 2026 8:29 AM UTC
Question

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

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

12 replies

Legend
Mar 25, 2026 8:23 PM UTC

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

Translate
Peter Kahrel
Community Expert
Community Expert
Mar 24, 2026 1:28 PM UTC

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 = ‘’;

 

Translate
Community Expert
Mar 23, 2026 10:08 AM UTC

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

These two should be helpful for your usecase

Translate
-Manan
Chetan SAuthor
Inspiring
Mar 24, 2026 12:31 PM UTC

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);

 

Translate
Community Expert
Mar 24, 2026 12:41 PM UTC

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.

Translate
-Manan