Free Support Forum - aspose.com

Unable to get Font Underline Style from speaker Notes

Hi,

I have applied different font underline styles like dash,double dash,dotted etc...in speaker notes. By using Portion class,I could able to check whether UnderLine applied or not. But I'm unable to get the actual style applied to the text.

Kindly share me the code to get the exact underline style applied to the text using c#.

Thanks

Ponraj.M

Hi Ponraj. M,


I like to share that we are also following you in this forum thread for some what similar inquiries. In case of PPT, Aspose.Slides only offers only Boolean variable to define the text is underlined or not. However, PPTX gives you more enriched controls including font underline type and strike through. When you extract PPT slide notes and add them to word, you need to have mapping of different bullet types in two different API’s.Please use the following sample code to serve the purpose. Also, the following code does extract different bullet types and their characters from PPT notes using Aspose.Slides. But it does not provide their mapping in Aspose.Words to generate accurate bullet in word document. For this you already have requested the same in this forum thread and Aspose.Words team will help you better in this regard.


public static void GetPptxFont()
{
String MyDir = “D:\Aspose Data\”;

Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(MyDir + “Sample_NotesPage.pptx”);
// Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(MyDir + “Bullets.pptx”);

// Insert string into document.
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder();
Aspose.Slides.Pptx.NotesSlideEx note;
foreach (SlideEx sld in pres.Slides)
{
//Getting notes slides
note = sld.NotesSlide;

if (note != null)
{
builder.Write(“Slide Notes for Slide:” + sld.SlideNumber.ToString() + “\n\n”);

foreach (ShapeEx shape in note.Shapes)
{
if (shape is AutoShapeEx)
{
AutoShapeEx ashp = (AutoShapeEx)shape;

if (ashp.TextFrame != null)
{
ParagraphEx para = null;
// foreach (ParagraphEx para in ashp.TextFrame)
for (int i = 0; i < ashp.TextFrame.Paragraphs.Count;i++ )
{
para = ashp.TextFrame.Paragraphs[i];
//Set list formats
if (para.HasBullet && para.ParagraphFormat.BulletType == BulletTypeEx.Numbered)
{
if (builder.ListFormat.List == null)
{
if (para.ParagraphFormat.NumberedBulletStyle == Aspose.Slides.Pptx.NumberedBulletStyleEx.BulletRomanLCPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(Aspose.Words.Lists.ListTemplate.NumberLowercaseRomanDot);
else if (para.NumberedBulletStyle == Aspose.Slides.Pptx.NumberedBulletStyleEx.BulletArabicPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletSquare);
}
}
else if (para.HasBullet && para.ParagraphFormat.BulletType == BulletTypeEx.Symbol)
{
char BulletChar=para.ParagraphFormat.BulletChar;
}

else if (para.HasBullet && para.ParagraphFormat.BulletType == BulletTypeEx.Picture)
{

}

foreach (PortionEx portion in para.Portions)
{

if (portion.Field == null && portion.Text!=String.Empty)
{
FontDataEx noteFont = portion.LatinFont;
//FontDataEx noteFont = portion.PortionFormat.LatinFont;
builder.Font.Name = noteFont.FontName;
builder.Font.Size = portion.FontHeight;

builder.Font.Underline = MapTextUnderline(portion.PortionFormat);
bool val=false;
if (portion.PortionFormat.FontBold == NullableBool.True)
val = true;
else
val = false;

builder.Font.Bold = val;
if (portion.PortionFormat.FontItalic == NullableBool.True)
val = true;
else
val = false;

builder.Font.Italic =val;

if(portion.PortionFormat.StrikethroughType==TextStrikethroughTypeEx.Double)
builder.Font.DoubleStrikeThrough = true;
else if (portion.PortionFormat.StrikethroughType == TextStrikethroughTypeEx.Single)
builder.Font.StrikeThrough = true;
else
{
builder.Font.DoubleStrikeThrough = false;
builder.Font.StrikeThrough = false;
}
builder.Write(portion.Text);
}
}
if (para.Text != “”)
builder.Writeln();
}
}
}
}

}//End if
}//End for
// Save output.
builder.Document.Save(MyDir + “outWord.docx”);
builder.Document.Save(MyDir + “out.pdf”);
builder.Document.Save(MyDir + “out.tiff”);
}

public static Aspose.Words.Underline MapTextUnderline(PortionFormatEx format)
{
if (format.FontUnderline == TextUnderlineTypeEx.Dashed)
return Aspose.Words.Underline.Dash;
else if (format.FontUnderline == TextUnderlineTypeEx.DotDash)
return Aspose.Words.Underline.DotDash;
else if (format.FontUnderline == TextUnderlineTypeEx.DotDotDash)
return Aspose.Words.Underline.DotDotDash;
else if (format.FontUnderline == TextUnderlineTypeEx.Dotted)
return Aspose.Words.Underline.Dotted;
else if (format.FontUnderline == TextUnderlineTypeEx.Double)
return Aspose.Words.Underline.Double;
else if (format.FontUnderline == TextUnderlineTypeEx.DoubleWavy)
return Aspose.Words.Underline.WavyDouble;
else if (format.FontUnderline == TextUnderlineTypeEx.Heavy)
return Aspose.Words.Underline.Thick;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyDashed)
return Aspose.Words.Underline.DashLongHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyDotDash)
return Aspose.Words.Underline.DotDashHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyDotDotDash)
return Aspose.Words.Underline.DotDotDashHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyDotted)
return Aspose.Words.Underline.DottedHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyLongDashed)
return Aspose.Words.Underline.DashLongHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.HeavyWavy)
return Aspose.Words.Underline.WavyHeavy;
else if (format.FontUnderline == TextUnderlineTypeEx.LongDashed)
return Aspose.Words.Underline.DashLong;
else if (format.FontUnderline == TextUnderlineTypeEx.None)
return Aspose.Words.Underline.None;
else if (format.FontUnderline == TextUnderlineTypeEx.NotDefined)
return Aspose.Words.Underline.None;
else if (format.FontUnderline == TextUnderlineTypeEx.Single)
return Aspose.Words.Underline.Single;
else if (format.FontUnderline == TextUnderlineTypeEx.Wavy)
return Aspose.Words.Underline.Wavy;
else if (format.FontUnderline == TextUnderlineTypeEx.Words)
return Aspose.Words.Underline.Words;
else
return Aspose.Words.Underline.None;

}

Many Thanks,

Thanks a lot. I will get back to you if I have any doubts.

Hi ,

PPT ==> In bullets and Numbering format, I am not getting the numbers in sequence.

Input:

A. This is letter A

B. This is letter B

Output:

A. This is leter A

A. This is letter B

Same issue I'm facing for numbers also. Kindly help to resolve thi issue.

Hi Ponraj,


Thanks for inquiring further. As I have shared with you in my last post that the bullet mapping is to be done in Aspose.Words to use PPT bullets using Aspose.Slides. We have already shared the mechanism for extracting the bullet type from PPT using Aspose.Slides over this link. Our respective Aspose.Words team member will help you further in this regard to provide mapping in Aspose.Words documentation in response to your this query.

Many Thanks,