Open XML Attributes in the Generated HTML



I’m using Apose.Slides to convert a powerpoint document to HTML (SVG format). Is it possible to add data attributes to the Open XML elements and have then appear in the HTML?

For example, setting the attribute data-id on run elements and having then appear in the html as data attributes on the tspan elements (or whichever element they happen to map to).

Thank you.



Can you please share your requirements in form of sample. We will investigate on our end to help you out.


Hi Adnan,

Here’s a full walk-through of what I’m hoping to do with some examples in the attachments.

1. Attach attributes to a:p elements in the xml of a powerpoint document using the following code (see attachment “output.xml” for the result):

// @param root: This is a Slide, SlideLayout or SlideMaster element.
private static void AttachIdToParagraphs(OpenXmlPartRootElement root)
        IEnumerable<A.Paragraph> paragraphs = root.Descendants<A.Paragraph>();

        foreach (A.Paragraph paragraph in paragraphs)
                string ns = "";
                paragraph.SetAttribute(new OpenXmlAttribute("attr-name", ns, "attr-value"));

                // -- OR ---
                paragraph.SetAttribute(new OpenXmlAttribute("attr-name", "", "attr-value"));

2. Generate a HTML document from the edited powerpoint using Aspose.Slides (see attachment “output.html” for the result):

using (Presentation pptx = new Presentation("file/path/to/edited/pptx"))
        HtmlOptions htmlOpt = new HtmlOptions
                HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false),
                SvgResponsiveLayout = true
        pptx.Save(htmlfile, SaveFormat.Html, htmlOpt);

As you can see the attribute “attr-name” was not reflected in the generated HTML. I’m hoping there’s a way to attach some attributes and have them reflect in the generated HTML. Please see attachment “desired-output.html” for an example of the desired output where the attribute has been added to the element. (49.3 KB)

Thank you,



I have observed your comments. You can create your own implementation of IHtmlController. Please visit this documentation link for more details.


Thanks Adnan. Can this be done for word documents? I’m again looking for a way to add some sort of mapping between the document’s open xml paragraph elements and the generated html elements (SVG Format).

For example:

1. Add attributes to the open xml elements.

using (WordprocessingDocument document = WordprocessingDocument.Open("file/path/to/docx", true))
    Body body = document.MainDocumentPart.Document.Body;

    foreach (Paragraph paragraph in body.Descendants<Paragraph>())
        paragraph.SetAttribute(new OpenXmlAttribute("attr-name", "namespace", "attr-value"));


2. Generate the HTML file from the edited word document using Apose.Words.

using (Aspose.Words.Document document = new Aspose.Words.Document("file/path/to/edited/docx")
    SvgSaveOptions options = new SvgSaveOptions
        PrettyFormat = true,
        UpdateFields = false,
        UseAntiAliasing = true,
        MemoryOptimization = true,
        ExportEmbeddedImages = true,
        OptimizeOutput = true,
        ShowPageBorder = false,
        FitToViewPort = false,
        UpdateSdtContent = false,
        UseHighQualityRendering = true,
        UpdateLastSavedTimeProperty = false,
        DmlRenderingMode = DmlRenderingMode.DrawingML,
        TextOutputMode = SvgTextOutputMode.UseSvgFonts
     document.Save("Output.html", options);

3. Output.html.

<g transform="matrix(1,0,0,1,0,0)">
    <text attr-name="attr-value">
	    <tspan x="0" y="39.124000549" font-family="Georgia">Text in run</tspan>



We are checking this scenario related to Aspose.Words and will get back to you soon.


Hi Awais,

Any update on this?



We had logged your requirement in our issue tracking system. Your ticket number is WORDSNET-18743. We will further look into the details of this requirement and will keep you updated on the status of the linked issue.