0

I have a PPD document in which I need to append some custom XML data for reference. My xml data is like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:c16r2="http://schemas.microsoft.com/office/drawing/2015/06/chart">

<c:date1904 val="0"/>

   other data...

</c:chartSpace>

I was trying to add metadata like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:c16r2="http://schemas.microsoft.com/office/drawing/2015/06/chart">

<c:date1904 val="0"/>

<c:authorMeta>
    <c:authorId>23</c:authorId>
    <c:authorName>User 1</c:authorName>
</c:authorMeta>

   other data...

</c:chartSpace>

But looks like PowerPoint remove those contents from the presentation. Am I missing anything? What is the correct way to resolve this issue?

Update:

There is an open-source library called pptgenjs used to create pptx files. Which creating the chart the library concatenates the XML tags and creates a chart.xml file. While doing this thing I was trying to add some custom meta passed by the user. But while opening this in Powerpoint the tags are automatically removed. That's why I asked if there any specific specs to add custom tags in pptx XML files.

How the custom XML added?

I was using the PptxGenJs library to create the presentation. In that library, I edited the makeXmlCharts function and added my custom XML data into it.

   function makeXmlCharts(rel) {
      var strXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
      // other code
      strXml += '<customTag>data</customTag>'
      // other code

      return strXml;
   }

And finallay using the ppt.write('base64') to get the base64 data.

pptx.write('base64').then(async function(data) {
  await PowerPoint.run(async function(context) {
    context.presentation.insertSlidesFromBase64(data);
    await context.sync();
  });
}).catch(err=> {
  console.log(err)
})

This is how I insert the edited XML data into the PPTX file.

Mari Selvan
  • 3,598
  • 3
  • 21
  • 36
  • Assuming that you meant PPTX rather than PPD, is there some reason your metadata *must* be added via XML. Powerpoint supports tags. Every shape, slide and presentation can hold any number of named tags (strings). Very simple to add and use in VBA ... not sure whether they have an interface for them in office-js though. – Steve Rindsberg Feb 09 '21 at 15:38
  • Please give more information about how you are adding this XML and what you mean when you say that "PowerPoint remove those contents". – Rick Kirkham Feb 10 '21 at 00:23
  • @RickKirkham more detail added. – Mari Selvan Feb 10 '21 at 02:01
  • I still don't see how you are adding custom XML to a PPTX file. Are you using methods in the Office JavaScript library? If so, please show the code. If not, how are getting the XML from chart.xml into a PPTX file? – Rick Kirkham Feb 10 '21 at 06:12
  • @RickKirkham added the full code sample. – Mari Selvan Feb 10 '21 at 07:41
  • Can you share a file created with PptGenJs with your custom tags? I assume they will also disappear if you open the file in desktop powerpoint, and just copy paste slides between decks? – Onur Onder Mar 18 '21 at 22:28

0 Answers0