PPT to JPEG conversion: Text completely mixed up

Hi

I have attached a ppt Test.ppt which contains only one slide. When I convert it to JPEG using the below code the text is all mixed up. The alignment is completely lost. I have attached the JPEG image also. Can you please look into it and diagnose the problem. Please let me know the solution for it.

Thanks so much

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;

}

}

for (int j = 0; j < textSlide.Placeholders.Count; j++) {

TextHolder th = textSlide.Placeholders[j] as TextHolder;

if (th != null) {

foreach (Paragraph para in th.Paragraphs) {

if (para.HasBullet && para.BulletType == BulletType.Symbol) {

bulletFontIndex = para.BulletFontIndex;

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;

}

}

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;

}

}

}

}

}

}

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");

}

}

Hi,

To simplify things I reduced the number of steps to just the following lines of code and still the JPG image obtained has text all jumbled up, Request you to please respond asap. Thanks a lot.

Code:

bool hasAudioVideo;
Presentation imagePres = new Presentation (@"C:\CIS_Display_Presentation_adapted_for_EA_test_Original.ppt");
int slideWidth = imagePres.SlideSize.Width;
int slideHeight = imagePres.SlideSize.Height;
Slide imageSlide = null;
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);
}

}
for (int j = 1; j <= imagePres.Slides.LastSlidePosition; j++) {
imageSlide = imagePres.GetSlideByPosition(j);
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;
}
}
}
Image image = imageSlide.GetThumbnail(new Size(2498, 1360));
image.Save("C:\\Test.jpg");
}

I figured out that if we open the ppt and then go to Animation tab and set the property Animate as No animation for all the elements in the slide then the JPEG obtained is proper.

How do I disable to animation in the ppt?

I used

shape.AnimationSettings.AnimateBackground = false

but doesnt seem to work.

Pls let me know the solution for this.

Thanks

We will look into this issue, animation should not be a problem.