We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert HTML to PPTX

I am using the sample code below to attempt to convert an html file to pptx. (this is provided in this link

http://www.aspose.com/docs/display/slidesnet/Importing+and+Exporting+HTML+Text+in+PPTX )

//Next convert to powerpoint
//Create Empty presentation instance//Create Empty presentation instance
//using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation())
//Create Empty presentation instance//Create Empty presentation instance
using (Presentation pres = new Presentation())
{
//Acesss the default first slide of presentation

ISlide slide = pres.Slides[0];

//Adding the AutoShape to accomodate the HTML content
IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10);

ashape.FillFormat.FillType = FillType.NoFill;

//Adding text frame to the shape
ashape.AddTextFrame("");

//Clearing all paragraphs in added text frame
ashape.TextFrame.Paragraphs.Clear();

//Loading the HTML file using stream reader
TextReader tr = new StreamReader(“file.html”);

//Adding text from HTML stream reader in text frame
ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());

//Saving Presentation
pres.Save(“output.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

}


However I am getting build errors with ISlide not being found, IAutoShape not being found. I have the latest .dll 8.3 and I am reference the correct assemblies with my using statement.

Any ideas of what would be causing the build errors? Does this sample code need to be updated?

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

Well, the sample code you are using is for our new unified version of Aspose.Slides for .NET. This new version resolves the inter conversion issues between PPT and PPTX format. You can download the latest unified version from here and let us know in case you still face any issue.

Thanks & Regards,

Installing that works however my resultant pptx file is empty. Attached is the html file I am trying to get displayed as a pptx, I changed file ext to .txt to upload (it is actually created first from a pdf to html using the code below).


Any thoughts?

finalOutputDoc.Save(@“C:\temp\temp.html”, Aspose.Pdf.SaveFormat.Html);

//Next convert to powerpoint
//Create Empty presentation instance//Create Empty presentation instance
//using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation())
//Create Empty presentation instance//Create Empty presentation instance
//Create Empty presentation instance//Create Empty presentation instance
using (Presentation pres = new Presentation())
{
//Acesss the default first slide of presentation

ISlide slide = pres.Slides[0];

//Adding the AutoShape to accomodate the HTML content
IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10);

ashape.FillFormat.FillType = FillType.NoFill;

//Adding text frame to the shape
ashape.AddTextFrame("");

//Clearing all paragraphs in added text frame
ashape.TextFrame.Paragraphs.Clear();

//Loading the HTML file using stream reader
TextReader tr = new StreamReader(@“C:\temp\temp.html”);

//Adding text from HTML stream reader in text frame
ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());

//Saving Presentation
pres.Save(@“C:\temp\output.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

}

Any ideas on the above issue?

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

Thank you for the details.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: SLIDESNET-35078. You will get a notification via this forum thread once the issue gets resolved.

Sorry for the inconvenience,

Any status update on this yet?

Hi,

Well, your reported issue is currently pending for investigation. Our development team will schedule and investigate the issue on its due turn based on first come and first serve policy for normal support queries. First priority is given to the paid Priority Support and Enterprise Support customers / queries. Also, I have requested the development team to share the feedback once they are done with the investigation of your issue.

Thanks & Regards,

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

Hi,

Our
development team has further checked your reported issue and noticed that the text is actually imported to PPTX file but has no
fill defined, i.e. it is rendered invisible. As a temporary workaround, you can
set the fill type explicitly to Solid as mentioned in the below sample code:

//Create Empty
presentation instance

using (Presentation pres = new
Presentation())

{


//Acesss the default first slide of
presentation


ISlide slide = pres.Slides[0];


//Adding the AutoShape to accomodate the HTML
content


IAutoShape ashape =
slide.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle,
10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10);


ashape.FillFormat.FillType = FillType.NoFill;


//Adding text frame to the shape


ashape.AddTextFrame("");


//Clearing all paragraphs in added text frame


ashape.TextFrame.Paragraphs.Clear();


//Loading the HTML file using stream reader


TextReader tr = new StreamReader(@“C:\Data\temp.html”);


//Adding text from HTML stream reader in text
frame


ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());

foreach (var paragraph in
ashape.TextFrame.Paragraphs)

foreach
(var portion in
paragraph.Portions)


portion.PortionFormat.FillFormat.FillType = FillType.Solid;



//Saving Presentation


pres.Save(@“C:\Data\output.pptx”,
Aspose.Slides.Export.SaveFormat.Pptx);


}

Our
development team will further look into this issue and will try to provide a
fix in our future release.

Thanks
& Regards,

<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

This works however it looks like the image that is in the html file (the one I attached in an above post temp.txt) is not being pulled into the powerpoint…


Any ideas of how to pull this in as well?

Hi,

Thank you for the feedback.

I am unable to notice any images in your shared html
file. Could you please share the image files you are using in your html file to
help us test the issue at our end.

Thanks & Regards,

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

Sure the html is the following… and I have attached the .svg file (renamed it to a .png so it could be uploaded).


The svg file seems to not to be pulled into the powerpoint…

Test a text doc!!  
TESTER@@!  
Test a text doc!!  
TESTER@@!  

Hi,

Thank you for the details.

However, I am not able to open the SVG file you have
shared. It would be better if you can share the file by zipping it and then
uploading.

In the meantime, I used an SVG image at my end and tested
the scenario, I am able to reproduce the issue with the latest version of
Aspose.Slides for .NET. The issue has been registered in our issue tracking
system with issue id: SLIDESNET-35104.
You will be notified via this forum thread regarding any updates against this
issue.

Sorry for the inconvenience,

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

The issue where the image in the html file is not pulled into the powerpoint still seems to exist. I have the latest version of the aspose.slides DLL (14.2).


Any updates on this?

Hi,

I have discussed your issue with the development team and got the following reply.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

PowerPoint does not allow inserting objects into paragraph text. Any HTML data that is not a rich formatted text is filtered away during the import, this is quite normal. If you want to import pictures you need to import the entire slide(s) like this:

private const string HTML = @"..\..\..\temp.html";

private const string OUTPUT = @"..\..\..\output.pptx";

private static void DoImport()

{

using (Presentation pres = new Presentation())

{

using (TextReader tr = new StreamReader(HTML))

{

// Will add one or more slides, depends on the HTML contents

pres.Slides.AddFromHtml(tr);

}

//Saving Presentation

pres.Save(OUTPUT, Aspose.Slides.Export.SaveFormat.Pptx);

}

}

Now, unlike WMF or JPG graphics, SVG format in not supported by PowerPoint so the picture import is still not possible. we would suggest you to change the graphics format to something that is supported by PowerPoint natively.

Thanks & Regards,

Ok if this is the case is there anyway when saving the PDF to HTML (that I am then converting to powerpoint) to tell it that the images should be jpgs/pngs/etc?? The html generated always uses .svg files in the html after calling the below method (even if the images in the PDF were jpgs/pngs/etc)


finalOutputDoc.Save(tempHtmlFileName, Aspose.Pdf.SaveFormat.Html);

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

As your query is related to Aspose.Pdf API, I am moving this thread to Aspose.Pdf forum where one of my colleague will reply you accordingly.

Thanks & Regards,

Hi Al Belmondo,


Thanks for your inquiry. You may save images to PNG instead SVG, while converting PDF to HTML. Please check following code documentation link for the purpose.


Please feel free to contact us for any further assistance.

Best Regards,