Free Support Forum - aspose.com

How to filter out slides with audio/video files?

Hello,

I am required to convert .ppt slides to jpeg except those slides that have audio or video embedded in it. Can anybody tell me how to do it?

Thanks

Dear Appu_Achu,

If you want to check, if some slide has a VideoFrame or AudioFrame, you can do so by checking the type of shapes on a slide.

FYI : Videos are always linked not embedded. But audios can be linked or embedded. To check audio is embedded, check the AudioFrame.Embedded property returns true.

C#

//Check if any shape is audio or video frame

bool hasAudioVideo=false;

foreach(Shape shp in sld.Shapes)

{

if(shp is AudioFrame || shp is VideoFrame)

{

hasAudioVideo=true;

//break the loop

break;

}

}

VB.NET

'Check if any shape is audio or video frame

Dim hasAudioVideo As Boolean

For Each shp As Shape In sld.Shapes

If TypeOf shp Is AudioFrame Or TypeOf shp Is VideoFrame Then

hasAudioVideo = True

'Break the loop

Exit For

End If

Next

Dear Faiz,

Thank you so much for the reply. It worked.

Thanks Again,Aparna

Hello,

I am using the serialize method as follows,

MemoryStream ms = new MemoryStream();

Background BG = slide.Background;

newBG.Serialize(ms);

I want to use this stream 'ms' in system.Drawing to draw a image.

Image image = Image.FromStream(ms, true, true);

but it gives a exception "Parameter is not valid.". Can you please tell me how to convert it to a valid stream.

Thanks..

If you want to get Background picture, you can get in this way.

Background BG = slide.Background;

Aspose.Slides.Picture pic = pres.Pictures.GetPictureById(BG.PictureId);

Image image = pic.Image;

Hi,

The above method you have mentioned works only when the background is of "Picture or Texture Fill", does not work for solid or gradient fill.

If possible, can you please let me know the stream returned when using Serialize method is of what type?

Thanks

It contains lot of other information like X, Y, width, height, alternative text etc.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

If you want to get the image of slide background, then add an empty slide and then gets its thumbnail image via Presentation.GetThumbnail method and then delete the newly added slide via Presentation.Slides.Remove method.

Thanks a lot.

The requirement is that I want ot convert the slides to jpeg.but the quality is not very good when seen using large screens. So my idea is to write the text using system.drawing Graphics (using the anti-aliasing and the hinting property). So i thought I can serialize each and every items like background, shape etc and draw it using graphics.drawimage or some other way (not sure). But i guess it is not posssible now.

One more thing, I used the anti-alias property of font quality in aspose but there seems no difference in the font quality.

int fontIndex = por.FontIndex;

FontEntity fontEntity = textPres.Fonts[fontIndex];

fontEntity.Quality = FontQuality.ANTIALIASED_QUALITY;

I am doing the above thing for each and every slide and then saving the entire PPT. Then I am saving the slides as jpeg using GetThumbNail(). But there seems to be no difference. Is this the right way to do it.

Thanks

Dear Appu,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Are you getting blurry images? If so, please use Aspose.Slides 2.8.4.0 from this link.

http://www.aspose.com/community/files/51/file-format-components/aspose.slides/default.aspx

In case, if you are still having problem, please attach your source ppt. Please also check thumbnail images taken from other ppts too.

Also, to get image with higher resolution, you need to give scaling factor to the Slide.GetThumbnail

For example, you can try

Slide.GetThumbnail(1.0, 1.0)

Or

Slide.GetThumbnail(2.0, 2.0)

Or

Slide.GetThumbnail(3.0, 3.0); // this will give you 2160 x 1620 image

Hi,

I am using the following piece of code for looping through the slides in a ppt.

IEnumerator slides = pres.Slides.GetEnumerator();

int j = 0;

while (slides.MoveNext()) {

j = j + 1;

Slide slide = (Slide)slides.Current;

image = slide.GetThumbnail(new Size(slideWidth, slideHeight));

image.Save("C:\\Slides\\Slide" + j + ".jpg",ImageFormat.Jpeg);

);

}

But sometimes what happens is that if there are say 16 slides, after converting to Jpeg there are 17 images. One of the slide is converted twice. But one of the them do not have all the contents of the slide and the other one does.

The same thing happens if I use foreach(Slide slide in slides) instead of while (slides.MoveNext()) {}

Please let me know what I can do regarding this.

Thanks

Dear Appu_Achu,

Presentation.Slides contains normal slides as well as master slides. So if you want to get the images of normal slides, you should use

Presentation.GetSlideByPosition and Presentation.Slides.LastSlidePosition

e.g

Presentation pres = new Presentation("c:\\source.ppt");

for (int i = 1; i <= pres.Slides.LastSlidePosition; i++)

{

Slide sld = pres.GetSlideByPosition(i);

System.Drawing.Image thumb = sld.GetThumbnail(1.0, 1.0);

thumb.Save("c:\\sld" + i + ".jpg");

}

Thank you so much. Now it works fine.

Hi,

I am using Aspose.Slides to process a ppt. I loop through all the slides and set the anti-aliasing property for the text and then writing the presentation again. But the bullets in the paragraph are not written properly. for example if i am using a diamond bullet it is converted to alphabet 'v'.. what do i do. kindly give me some suggestions.

foreach (Shape shape in textSlide.Shapes) {

if (shape is Aspose.Slides.Rectangle) {

if (shape.TextFrame != null) {

foreach (Paragraph para in shape.TextFrame.Paragraphs) {

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;

}

}

}

tempPPTName = System.IO.Path.GetTempFileName();

textPres.Write(tempPPTName);

Please provide source presentation to check problem with bullets.

If I’m not mistaken the antialiasing property exists for fonts but actually do nothing in MS PowerPoint.

Also please always create new thread in the forum for new questions and requests.

I figured it out myself. Thanks.