Hi Team,
Hi Vishnu,
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