Hi
I have attached 2 Presentations - 1. PPT_1.ppt and
2. PPT_2.ppt
I have also attached the JPEG images obtained after converting the PPTs to JPEGs using Aspose.Slides in the following folders
1. JPEGs from PPT_1.zip
2. JPEGs from PPT_2.zip
I have used the code given in the end to convert the PPT.
PPT_1 is the orginal ppt. PPT_2 was created by following the steps given below
1. Copy PPT_1 as PPT_2
2. Delete all the slides from PPT_2
3. Copy all the slides from PPT_1 to PPT_2
PROBLEM:
If we compare the Jpegs obtained using the 2 ppts we can see that Jpeg's from PPT_1 does not render the bullets(i.e bullets appear as alphabets like 'u') whereas Jpeg's obtained from PPT_2 renders the bullets correctly.
I debuged through my code and I saw that for PPT_1 the paragraphs are not identified (paragraph count = 0)and hence skips the whole prcessing of replacing unistalled fonts with wingding font and hence the bullets are not rendered.
Where as for PPT_2 the paragraphs are identified properly and the uninstalled fonts are replaced with wingding.
Why is there so much difference even though the content of the PPTs are the same? Request you to provide a solution for the same.
Code:
bool hasAudioVideo = false;
Slide textSlide = null;
bool exists = false;
char bulletChar;
int bulletFontIndex = 0;
short bulletHeight;
Color bulletColor;
Aspose.Slides.License license = new Aspose.Slides.License();
Assembly currentAssembly = Assembly.GetExecutingAssembly();
string[] arrResources = currentAssembly.GetManifestResourceNames();
foreach (string resource in arrResources) {
if (resource.EndsWith("Aspose.Slides.lic")) {
license.SetLicense(resource);
}
}
Presentation textPres = new Presentation("C:\\PPT_1.ppt");
System.Drawing.FontFamily[] families = System.Drawing.FontFamily.Families;
Fonts fonts = textPres.Fonts;
//Setting the anti-alias for the text presetn in the slides.
for (int i = 1; i <= textPres.Slides.LastSlidePosition; i++) {
textSlide = textPres.GetSlideByPosition(i);
foreach (Shape shape in textSlide.Shapes) {
if (shape is Aspose.Slides.Rectangle) {
if (shape.TextFrame != null) {
foreach (Paragraph para in shape.TextFrame.Paragraphs) {
bool hasBullet = para.HasBullet;
if (hasBullet == true) {
para.HasBullet = true;
if (para.BulletType == BulletType.Symbol) {
bulletChar = para.BulletCharacter;
bulletFontIndex = para.BulletFontIndex;
exists = false;
foreach (System.Drawing.FontFamily family in families) {
if (fonts[bulletFontIndex].FontName == family.Name) {
exists = true;
break;
}
}
if (exists == false) {
fonts[bulletFontIndex].FontName = "WingDings";
}
bulletHeight = para.BulletHeight;
bulletColor = para.BulletColor;
para.BulletColor = bulletColor;
para.BulletHeight = bulletHeight;
para.BulletCharacter = Convert.ToChar(bulletChar);
}
}
if (para.Portions != null) {
foreach (Portion por in para.Portions) {
string text = por.Text;
int fontIndex = por.FontIndex;
FontEntity fontEntity = textPres.Fonts[fontIndex];
fontEntity.Quality = FontQuality.ANTIALIASED_QUALITY;
}
}
}
}
}
else if (shape is Aspose.Slides.PictureFrame) {
PictureFrame pf = (PictureFrame)shape;
int b = pf.Brightness;
pf.Brightness = EAPConstants.BRIGHTNESS;
b = pf.Brightness;
}
}
}
string tempPPTName = System.IO.Path.GetTempFileName();
textPres.Write(tempPPTName);
//Presentation imagePres = new Presentation(OriginalFilePath);
Presentation imagePres = new Presentation(tempPPTName);
int slideWidth = imagePres.SlideSize.Width;
int slideHeight = imagePres.SlideSize.Height;
Slide imageSlide = null;
for (int j = 1; j <= imagePres.Slides.LastSlidePosition; j++) {
imageSlide = imagePres.GetSlideByPosition(j);
tempPPTName = System.IO.Path.GetTempFileName();
hasAudioVideo = false;
foreach (Shape shape in imageSlide.Shapes) {
if (shape is AudioFrame || shape is VideoFrame) {
hasAudioVideo = true;
break;
}
}
if (hasAudioVideo == false) {
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs) {
if (codec.MimeType == "image/jpeg") {
ici = codec;
break;
}
}
//Importing the file.
Image image= imageSlide.GetThumbnail(new Size(1813, 1360));
string tempFileName = System.IO.Path.GetTempFileName();
image.Save
@"C:\JPEGs from PPT1\" + j + ".JPG");
}
}