PPTX to HTML Conversion with Image and Css styles in Seperate folder

Hi Team,

I am new to Aspose library. I have the requirement in .net platform to convert .pptx to .html and that too in the separate html page per slide. which i was able to achieve.As per the my understanding , what ever may be images in the pptx will be encrypted and using the same image in the HTML. But my requirement is that when converting .pptx to .html , there should be separate folder structure for the image and css style besides the html files. Is it possible through the Aspose library .Your support will be appreciate.

Regards,
Vishnu


Hi Vishnu,


I have observed your comments and discussed your requirements with our product team. An issue with ID SLIDESNET-38619 has been created in our issue tracking system to further investigate the possibility of implementing the requested feature support. This thread has been linked with the issue so that you may be automatically notified once the support will be available.

Best Regards,

@visuc9,

I have shared code snippet below. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.

class ExternalResourcesHtmlController : IHtmlFormattingController, ILinkEmbedController
{
const string Header = “\n” +
“\n” +
“\n” +
“<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>\n” +
“<meta http-equiv=“X-UA-Compatible” content=“IE=11”>\n” +
“”;

const string UrlTemplate = @"www.example.com/resources/resource{0}.{1}";
private readonly ResponsiveHtmlController m_controller = new ResponsiveHtmlController();
private readonly Dictionary<int, string> m_resourceUrls = new Dictionary<int, string>();
public void WriteDocumentStart(IHtmlGenerator generator, IPresentation presentation)
{
    generator.AddHtml(Header);
}
void IHtmlFormattingController.WriteDocumentEnd(IHtmlGenerator generator, IPresentation presentation)
{
    ((IHtmlFormattingController) m_controller).WriteDocumentEnd(generator, presentation);
}
void IHtmlFormattingController.WriteSlideStart(IHtmlGenerator generator, ISlide slide)
{
    ((IHtmlFormattingController) m_controller).WriteSlideStart(generator, slide);
}
void IHtmlFormattingController.WriteSlideEnd(IHtmlGenerator generator, ISlide slide)
{
    ((IHtmlFormattingController) m_controller).WriteSlideEnd(generator, slide);
}
void IHtmlFormattingController.WriteShapeStart(IHtmlGenerator generator, IShape shape)
{
    ((IHtmlFormattingController) m_controller).WriteShapeStart(generator, shape);
}
void IHtmlFormattingController.WriteShapeEnd(IHtmlGenerator generator, IShape shape)
{
    ((IHtmlFormattingController) m_controller).WriteShapeEnd(generator, shape);
}
public LinkEmbedDecision GetObjectStoringLocation(
    int id,
    byte[] entityData,
    string semanticName,
    string contentType,
    string recomendedExtension)
{
    switch (contentType)
    {
        case "image/svg+xml":
        {
            return LinkEmbedDecision.Embed;
        }
        default:
        {
            string url = string.Format(UrlTemplate, id, recomendedExtension);
            m_resourceUrls.Add(id, url);
            return LinkEmbedDecision.Link;
        }
    }
}
public string GetUrl(int id, int referrer)
{
    return m_resourceUrls[id];
}
public void SaveExternal(int id, byte[] entityData)
{
    string fileName = Path.GetFileName(m_resourceUrls[id]);
            
    // upload to the correct web folder or any other actions required to store resources
            
    // example: simply store in the same folder
    // File.WriteAllBytes(fileName, entityData);
}

}

using (Presentation pres = new Presentation(“pres.pptx”))
{
ExternalResourcesHtmlController externalResourcesHtmlController = new ExternalResourcesHtmlController();

HtmlOptions htmlOptionsEmbed = new HtmlOptions(externalResourcesHtmlController)
{
    HtmlFormatter = HtmlFormatter.CreateCustomFormatter(externalResourcesHtmlController)
};
pres.Save("pres.html", SaveFormat.Html, htmlOptionsEmbed);

}

Best Regards,

Adnan Ahmad

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan