Sign In  Sign Up Live-Chat

Symbol in table cell

Last post 09-08-2008, 3:01 PM by msfaiz. 5 replies.
Sort Posts: Previous Next
  •  09-03-2008, 10:27 PM 142295

    Symbol in table cell

    How can I insert symbols (ex. left and right arrows), shapes (diamond, triangle) found in Windings, Windings2 and Windings3 font type into table cells?
     
  •  09-04-2008, 5:10 AM 142343 in reply to 142295

    Re: Symbol in table cell

    Attachment: Present (inaccessible)

    Dear Patrick,

    Thanks for considering Aspose.Slides.

    To add symbols, you must know their (hex or decimal) codes and their fonts. You can find them out by creating such symbols in some presentation using MS-PowerPoint and then inspecting their values in debugger with the help of Aspose.Slides.

    Below is the sample code that inserts 4 such symbols, it is fully commented for your help and I have also attached its output.

    //Create an empty presentation

    Presentation pres = new Presentation();

    //Get the empty slide

    Slide sld = pres.GetSlideByPosition(1);

    //Add a rectangle shape and textframe

    Table tbl = sld.Shapes.AddTable(100, 100, 4000,2000,3,3);

    //Get the textframe

    TextFrame tf = tbl.GetCell(1, 1).TextFrame;

    //Add Font and note its index

    //You will have to add symbol charset wingdings font

    FontEntity rawSymbolFontEnt = new FontEntity(pres, pres.Fonts[0]);

    rawSymbolFontEnt.CharSet = FontCharSet.SYMBOL_CHARSET;

    rawSymbolFontEnt.FontName = "Wingdings";

    int rawSymbolFontIndex = pres.Fonts.Add(rawSymbolFontEnt);

    //Add symbol characters from their hex codes

    StringBuilder sb = new StringBuilder();

    sb.Append((char)0xf0e0);

    sb.Append((char)0xf0df);

    sb.Append((char)0xf0e8);

    sb.Append((char)0xf0e7);

    //Write the text in the portion

    Portion port=tf.Paragraphs[0].Portions[0];

    port.Text = sb.ToString();

    //Set the RawSymbolFontIndex property

    port.RawSymbolFontIndex = rawSymbolFontIndex;

    //Write presentation on disk

    pres.Write("c:\\outSymbols.ppt");


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  09-05-2008, 5:52 PM 142683 in reply to 142343

    Re: Symbol in table cell

    Thanks Shakeel! Your sample code is helpful. How can I add a space and some text (with a font type of Arial) after the symbol in the table cell?
     
  •  09-07-2008, 5:30 PM 142785 in reply to 142683

    Re: Symbol in table cell

    You can add a new portion and add it in your paragraph. Here is the code example. Insert them just before writing the presentation on disk in my above code.

     

    //Add a portion with space and some more text

    Portion newPort = new Portion(port);

    newPort.Text = " some arial text.";

    //Assume Presentation.Fonts[0] has arial

    newPort.FontIndex = 0;

    //Add it in paragraph's portions collection

    tf.Paragraphs[0].Portions.Add(newPort);


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  09-08-2008, 10:56 AM 142945 in reply to 142785

    Re: Symbol in table cell

    Thanks Shakeel! Can you show me how to add $1 to a table cell? I tried setting the escapement property of the portion; but can't seems to get it right.
     
  •  09-08-2008, 3:01 PM 142991 in reply to 142945

    Re: Symbol in table cell

    In $1, 1 is actually a superscript. You should add this code to insert it.

    //Add two more portions for $1

    Portion newPort1 = new Portion(port);

    newPort1.Text = "$";

    tf.Paragraphs[0].Portions.Add(newPort1);

    Portion newPort2 = new Portion(newPort1);

    newPort2.Text = "1";

    newPort2.Escapement = 30; //To make the 1 superscript

    tf.Paragraphs[0].Portions.Add(newPort2);


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
View as RSS news feed in XML