We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replacing TextFrameEx

Having had trouble with "Out of Memory" errors, I am looking at replacing some of our jpg's which just contain text. I would have liked to been able to dump rtf into a TextFrame. This does not seem to be possible (from reading other posts here).

The solution that I am currently working on is to create a single page PPTx with a text field on it. I want then to be able to copy that TextFrameEx, with its formatting, into a slide in the final PresentationEx. Can't find how to do that.

I have a TextFrameEx placeholder in a slide in the final PresentationEx. I would like to replace that with the TextFrameEx from the single page PPTx.

Any ideas? Thanks for the help.

Hi Brad,

Thanks for your interest in Aspose.Slides.

We regret to inform you that you cannot copy the text frame to a place holder. However, you can add the placeholder or shape in destination slide with same specifications as in source slides and then add text frame to the destination shape. You can then copy the contents of the source TextFrame to destination TextFrame on paragraphs and portions level. Please use the following code snippet as this will help you in copying text from one TextFrame to another by keeping the formatting intact.

//Reading source and Destination Presentations
PresentationEx SourcePres = new PresentationEx("d:\\ppt\\Source.pptx");
PresentationEx DestPres = new PresentationEx("d:\\ppt\\notext.pptx");

//Reading the source text frame
AutoShapeEx aShp_Source = (AutoShapeEx)SourcePres.Slides[0].Shapes[0];
TextFrameEx TxtFrame_Source = aShp_Source.TextFrame;

//Creating a shape in the destination slide as in source slide
int ShpId = DestPres.Slides[0].Shapes.AddAutoShape(ShapeTypeEx.Rectangle, aShp_Source.X, aShp_Source.Y, aShp_Source.Width, aShp_Source.Height);
AutoShapeEx aShp_Dest = (AutoShapeEx)DestPres.Slides[0].Shapes[ShpId];

//Setting Shape Fill type and Line type to as of source shape
aShp_Dest.FillFormat.FillType = aShp_Source.FillFormat.FillType;
aShp_Dest.LineFormat.FillFormat.FillType = aShp_Source.LineFormat.FillFormat.FillType;

//Reading destination shape text frame
TextFrameEx TxtFrame_Dest = aShp_Dest.TextFrame;

//clearing all pargarphs

//Iterating through each paragraph of source shape TextFrame
foreach (ParagraphEx Paragraph_Source in TxtFrame_Source.Paragraphs)
    ParagraphEx newPara = new ParagraphEx();

    //Iterating through each portion of particular paragraph
    foreach (PortionEx Portion_Source in Paragraph_Source.Portions)
        // PortionEx oldPort = Paragraph_Source.Portions[0];
        PortionEx newPort = new PortionEx(Portion_Source);

        //Add new paragraph and new portion

    //Setting allighnmet of particular destiantion paragraph
    //to as of respective source paragraph
    newPara.RawAlignment = Paragraph_Source.RawAlignment;

    //Adding paragraph to destination TextFrame


Thanks and Regards,

Hi Mudassir,

Many Thanks. It worked well except that it did not keep the bullets from the source page (and one other later). I started tracking this down and found that the ParagraphEx had several bullet properties. I started to add these, then thought 'what happens if I create a new paragraph from the old?'. So I did. Then I did not have to copy all the portions either. You can see this in the sub copyTextFrame in PPTx.vb. Is there a problem with not copying the individual portions?

The other problem was that space characters got dropped before some of the color changes in the text (between TSDn and NOT, and TSDn and PROTECTED). I created a test program and put it in a zip. You can run the test program and create an output file.

I have done that. The original text is in P-IIN-0174.1 (PDB6).pptx in the documents folder. The output file is CreatePPTx.pptx in documents.

I did not include the bin directory. It needs to have Slides and perhaps DocumentFormat.OpenXml.dll.



Just noticed that it also dropped a space between TSDn and bbbbbbbb in the second line.

Probably not related to the color then, but something odd happening in the text?


Hi Brad,

The code snippet that you have presented is absolutely fine and the problem of missing space character issue is due to MS Office dictionary. MS PowerPoint underlines words with errors and save them as separate portions. Since word "TSDn " is has error as it is not a valid word, so it’s splits in portions. For successful execution either TSDn or similar words with errors be added in dictionary or spell-checking should be turned off and presentation resaved to store these templates as single portion. I have verified this fact on yours provided project as well.

As far as copying on paragraph level is concerned, there are certain text related properties that may be defined on portion level only and they may get reset. Since, you may not be using them right now, that is why may not feel the difference between copying contents on portion or paragraph level. Like, if you copy the text on TextFrame level, you will be able to copy all the paragraphs in the text frame but will lose all the formatting inside that.

Thanks and Regards,

Thanks Mudassir,

Turning off the spell checking did the trick. I noticed that there were other words that were not in the dictionary that did not lose the space after them (aaaaa for example). Thought that was odd, but all worked when the dictionary was turned off.

I re-enabled the portion copying since that might ultimately cause other problems according to your last message. I attached the PPTx.vb file with the copyTextFrame routine in case anyone else wants to use it.

Thanks again.