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.