Generate Images from PPT with Aspose.Slides

Hi,

I have written some code that renders and image for each slide of an imported PPT file, but the resulting jpgeg image is corrupted or ‘incomplete’, could you please direct me to an example of how this should be done properly?

Like this, but with a PPT instead of a PDF:

Thanks,
Paul.

Hi Paul,


Thanks for inquiring Aspose.Slides.

I have observed your requirements. Can you please share the source presentation along with generated corrupted output with us. Please also share the sample code used to reproduce the issue. I would also recommend you to please try using latest version of Aspose.Slides for .NET on your end as well.

Many Thanks,

Hi Mudassir,

To asnwer your questions:

Sorry I cannot send you the original PPT as it is owned by the client, however I believe the fault lies in my code, not the file I am rendering images from.

Here is the sample code:

Dim importPresentation As New Aspose.Slides.Presentation(filePath)
Dim saveOpts As New Aspose.Slides.SVGOptions
saveOpts.JpegQuality = 100

For i As Integer = 0 To importPresentation.Slides.Count - 1
If (i + 1) > 4 Then
Exit For
End If
Dim PageNumber As String = (i + 1).ToString
If i < 10 Then PageNumber = String.Concat(“0”, PageNumber)
importPresentation.Slides(i).SaveToSVG(Server.MapPath(“RenderedImages/” & fileName & “_” & PageNumber & “.jpg”), saveOpts)
Next

The corrupt rendered image is attached, as requested.

Many thanks,
Paul.

hello ,

Can you please explain this section of code :
For i As Integer = 0 To importPresentation.Slides.Count - 1
If (i + 1) > 4 Then
Exit For
End If
Dim PageNumber As String = (i + 1).ToString
If i < 10 Then PageNumber = String.Concat(“0”, PageNumber)
importPresentation.Slides(i).SaveToSVG(Server.MapPath(“RenderedImages/”
& fileName & “_” & PageNumber & “.jpg”), saveOpts)
because curentely i try to generate ppt with a picture of costumer but i dont find the best way , i have always this error : Unexpected Aspose.Slides.PptException: Picture creating error. Parent of a picture can’t be a null.

this is the code if you have any idea

SqlConnection cn = new SqlConnection(“chaine de connexion”);
// selection du nom de client
String selectString = “SELECT nom from client”;
String vName;
// Create an OleDbCommand object
SqlCommand cmd = new SqlCommand(selectString, cn);

cn.Open();

// Send the CommandText to the connection, and then build an OleDbDataReader
SqlDataReader reader = cmd.ExecuteReader();

txtclient.Text = “”;

while (reader.Read())

{

// txtclient.Text = reader[“nom”].ToString();
//vName = reader[“nom”].ToString();
vName = (string)reader[“nom”];

txtclient.Text = vName;

}

reader.Close();
cn.Close();

// Add picture of item
Picture pic1 = null;

if (txtclient.Text == “edf”)
{

pic1 = new Picture(pres, MapPath(".") + “/images/edf/edf.gif”);
}

/else if (txtclient.Text == “edf”)
{
pic1 = new Picture(pres, MapPath(".") + “/images/edf/edf.gif”);
}
else if (txtclient.Text == “airbus”)
{
pic1 = new Picture(pres, MapPath(".") + “/images/airbus/airbus.gif”);
}
/

int picid1 = pres.Pictures.Add(pic1);
int pictureWidth = pres.Pictures[picid1 - 1].Image.Width * 5;
int pictureHeight = pres.Pictures[picid1 - 1].Image.Height * 5;
int slideWidth = slide1.Background.Width;
int slideHeight = slide1.Background.Height;
int pictureFrameX = Convert.ToInt32(slideWidth / 2 - pictureWidth / 2);
int pictureFrameY = Convert.ToInt32(slideHeight / 2 - pictureHeight / 2 + 1000);
PictureFrame pf = slide1.Shapes.AddPictureFrame(picid1, pictureFrameX, pictureFrameY, pictureWidth, pictureHeight);

pf.AnimationSettings.EntryEffect = ShapeEntryEffect.ZoomIn;
// Add Slide Transition Effect
slide1.SlideShowTransition.EntryEffect = SlideTransitionEffect.CircleOut;

Hi Paul,


I have observed the code snippet shared. You are trying to save the SVG file as jpeg. This is wrong. Please try using the following sample on your end.

public static void SaveToSvg()
{
String path = “D:\Aspose Data\”;
Presentation pres = new Presentation(path + “Test.ppt”);
Aspose.Slides.SVGOptions saveOpts= new Aspose.Slides.SVGOptions();
saveOpts.JpegQuality = 100;
for (int i=1;i<=pres.Slides.LastSlidePosition;i++)
{
Slide slide= pres.GetSlideByPosition(i);
slide.SaveToSVG(path+“Slide_”+i.ToString()+".svg", saveOpts);
}


}

Many Thanks,

Thanks for your code Mudassi, but I do need them as jpg or png, how would I output to that format?

Also the rendered image is working, but the content is very jumbled, see sample attached. Is this the best Aspose.Slides can do?

Please note that your site does not allow me to upload .svg files, so I have renamed it to svg.jpg, you will need to remove the .jpg before viewing.

Thanks,
Paul

Hi Paul,


I like to share that Aspose.Slides supports to generate the the slide thumbnails in different formats like bmp, jpeg or png. Please visit this documentation link for your kind reference.


Many Thanks,

Thanks for your response, but that link only demonstrates how to create a thumbnail!

How do I create a full sized jpeg of each slide of a ppt/pptx?

Again this test will determine whether we purchase Aspose.total, or not.

Generating an image of a ppt/pptx file is now the only thing stopping us moving forward on this.

Regards,
Paul

Hi Paul,


I like to share that whatever dimension you will set the slide thumbnail for entire slide will be generated. Please use the following code line for generating the slide thumbnail.


//Getting the thumbnail image of the slide of a specified size
Image image = slide.GetThumbnail(1f,1f);


The factor 1f sets the size of actual slide in generated thumbnail. if you use 2f, then the slide thumbnail for twice the slide size will be generated.

Please share, if I may help you further in this regard.

Many Thanks,

Thanks, but…

What is the full namespace of ‘Image’ from:

Image image = slide.GetThumbnail(1f,1f);

Hi Paul,


You need to add reference to namespace System.Drawing. Please use the following statement in your sample code.

System.Drawing.Image

Many Thanks,