Interface ITextPart
Represents an individual text part in a paragraph.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.Base.dll
Syntax
public interface ITextPart
Properties
Font
Gets an IFont instance of the text part. Read-only.
Declaration
IFont Font { get; }
Property Value
Type | Description |
---|---|
IFont | The font of the TextPart. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//create instance for text body from shape
ITextBody textBody = shape.TextBody;
//Add first paragraph to text body
textBody.AddParagraph();
//Create instance for text part
ITextPart textPart = textBody.Paragraphs[0].AddTextPart("FirstParagraph, first TextPart");
//Create instance to hold font properties of text part
IFont font = textPart.Font;
//Set the bold style
font.Bold = true;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'create instance for text body from shape
Dim textBody As ITextBody = shape.TextBody
'Add first paragraph to text body
textBody.AddParagraph()
'Create instance for text part
Dim textPart As ITextPart = textBody.Paragraphs(0).AddTextPart("FirstParagraph, first TextPart")
'Create instance to hold font properties of text part
Dim font As IFont = textPart.Font
'Set the bold style
font.Bold = True
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Hyperlink
Returns an IHyperLink instance that represents the hyperlink for the specified textpart. Read-only.
Declaration
IHyperLink Hyperlink { get; }
Property Value
Type | Description |
---|---|
IHyperLink |
Text
Gets or sets the text content.
Declaration
string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The text value of the TextPart. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//create instance for text body from shape
ITextBody textBody = shape.TextBody;
//Add first paragraph to text body
textBody.AddParagraph();
//Create instance for text part
ITextPart textPart = textBody.Paragraphs[0].AddTextPart();
//Set text for the text part
textPart.Text = "FirstParagraph, first TextPart";
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'create instance for text body from shape
Dim textBody As ITextBody = shape.TextBody
'Add first paragraph to text body
textBody.AddParagraph()
'Create instance for text part
Dim textPart As ITextPart = textBody.Paragraphs(0).AddTextPart()
'Set text for the text part
textPart.Text = "FirstParagraph, first TextPart"
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
UnderlineColor
Gets or sets the underline color for the text.
Declaration
IColor UnderlineColor { get; set; }
Property Value
Type | Description |
---|---|
IColor |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//create instance for text body from shape
ITextBody textBody = shape.TextBody;
//Add first paragraph to text body
textBody.AddParagraph();
//Create instance for text part
ITextPart textPart = textBody.Paragraphs[0].AddTextPart();
//Set text for the text part
textPart.Text = "FirstParagraph, first TextPart";
IColor underlineColor = textPart.UnderlineColor;
//Set the text part underline color
underlineColor = ColorObject.Navy;
//Set underline type for text part
textPart.Font.Underline = TextUnderlineType.Double;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'create instance for text body from shape
Dim textBody As ITextBody = shape.TextBody
'Add first paragraph to text body
textBody.AddParagraph()
'Create instance for text part
Dim textPart As ITextPart = textBody.Paragraphs(0).AddTextPart()
'Set text for the text part
textPart.Text = "FirstParagraph, first TextPart"
Dim underlineColor As IColor = textPart.UnderlineColor
'Set the text part underline color
underlineColor = ColorObject.Navy
'Set underline type for text part
textPart.Font.Underline = TextUnderlineType.[Double]
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Methods
RemoveHyperLink()
Removes the hyperlink from the current textpart.
Declaration
void RemoveHyperLink()
SetHyperlink(String)
Sets the hyperlink to the textpart.
Declaration
IHyperLink SetHyperlink(string link)
Parameters
Type | Name | Description |
---|---|---|
System.String | link | Represents the address of the target hyperlink |
Returns
Type | Description |
---|---|
IHyperLink | Returns an IHyperLink instance. |
Remarks
The target can be a document path, web url, target slide, email_id.
Examples
//Create a new presentation.
IPresentation presDoc = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presDoc.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//create instance for text body from shape
ITextBody textBody = shape.TextBody;
//Add first paragraph to text body
textBody.AddParagraph();
//Create instance for text part
ITextPart textPart = textBody.Paragraphs[0].AddTextPart();
//Set HperLink for this textpart
IHyperLink hyperLink = textPart.SetHyperlink("www.syncfusion.com");
//Save the presentation to the file system.
presDoc.Save("Output.pptx");
//Close the presentation
presDoc.Close();
Dim presDoc As IPresentation = Presentation.Create()
‘Add slide to the presentation
Dim slide As ISlide = presDoc.Slides.Add(SlideLayoutType.Blank)
‘Add table to the slide
Dim table As ITable = slide.Shapes.AddTable(2, 2, 100, 120, 300, 200)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'create instance for text body from shape
Dim textBody As ITextBody = shape.TextBody
'Add first paragraph to text body
textBody.AddParagraph()
'Create instance for text part
Dim textPart As ITextPart = textBody.Paragraphs(0).AddTextPart()
'Set HperLink for this textpart
Dim hyperLink As IHyperLink = textPart.SetHyperlink("www.syncfusion.com")
‘Save the presentation
presDoc.Save("Sample.pptx")
‘Close the presentation
presDoc.Close()