Interface ITextPart
Represents an individual text part in a paragraph.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.Portable.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 |
---|
IHyperLink |
Examples
//Create a new presentation.
IPresentation ppDoc = Presentation.Create();
//Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
//Add a rectangle to the slide
IShape shape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 100, 100, 100, 100);
//Adds paragraph into the shape
IParagraph paragraph = shape.TextBody.AddParagraph();
//Adds text to the TextPart
paragraph.Text = "Google";
//Set hyperlink to the TextPart
IHyperLink hyperLink = paragraph.TextParts[0].SetHyperlink("https://www.google.com");
//Set screen tip to the hyperlink
hyperLink.ScreenTip = "This hyperlink navigates to Google site";
//Remove the hyperlink.
paragraph.TextParts[0].RemoveHyperLink();
//Save the presentation
ppDoc.Save("Sample.pptx");
//Close the presentation
ppDoc.Close();
'Create a new presentation.
Dim ppDoc As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = ppDoc.Slides.Add(SlideLayoutType.Blank)
'Add a rectangle to the slide
Dim shape As IShape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 100, 100, 100, 100)
'Adds paragraph into the shape
Dim paragraph As IParagraph = shape.TextBody.AddParagraph()
'Adds text to the TextPart
paragraph.Text = "Google"
'Set hyperlink to the TextPart
Dim hyperLink As IHyperLink = paragraph.TextParts(0).SetHyperlink("https://www.google.com")
'Set screen tip to the hyperlink
hyperLink.ScreenTip = "This hyperlink navigates to Google site"
'Save the presentation
ppDoc.Save("Sample.pptx")
'Close the presentation
ppDoc.Close()
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 |
---|
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()
Examples
//Create a new presentation.
IPresentation ppDoc = Presentation.Create();
//Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
//Add a rectangle to the slide
IShape shape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 100, 100, 100, 100);
//Adds paragraph into the shape
IParagraph paragraph = shape.TextBody.AddParagraph();
//Adds text to the TextPart
paragraph.Text = "Google";
//Set hyperlink to the TextPart
IHyperLink hyperLink = paragraph.TextParts[0].SetHyperlink("https://www.google.com");
//Set screen tip to the hyperlink
hyperLink.ScreenTip = "This hyperlink navigates to Google site";
//Remove the hyperlink.
paragraph.TextParts[0].RemoveHyperLink();
//Save the presentation
ppDoc.Save("Sample.pptx");
//Close the presentation
ppDoc.Close();
'Create a new presentation.
Dim ppDoc As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = ppDoc.Slides.Add(SlideLayoutType.Blank)
'Add a rectangle to the slide
Dim shape As IShape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 100, 100, 100, 100)
'Adds paragraph into the shape
Dim paragraph As IParagraph = shape.TextBody.AddParagraph()
'Adds text to the TextPart
paragraph.Text = "Google"
'Set hyperlink to the TextPart
Dim hyperLink As IHyperLink = paragraph.TextParts(0).SetHyperlink("https://www.google.com")
'Set screen tip to the hyperlink
hyperLink.ScreenTip = "This hyperlink navigates to Google site"
'Remove the hyperlink
paragraph.TextParts(0).RemoveHyperLink()
'Save the presentation
ppDoc.Save("Sample.pptx")
'Close the presentation
ppDoc.Close()
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 text for the text part
textPart.Text = "Syncfusion";
//Set HyperLink 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 text for the text part
textPart.Text = "Syncfusion"
'Set HyperLink for this textpart
Dim hyperLink As IHyperLink = textPart.SetHyperlink("www.syncfusion.com")
‘Save the presentation
presDoc.Save("Sample.pptx")
‘Close the presentation
presDoc.Close()