1

I opened this question in SO site but it seems is more appropiate here.

Inside an .pptx file we have this structure

Structure

I'm trying to edit the content of internal slide2.xml in ..\ppt\slides.

The slide2.xml content is like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:cSld><p:bg><p:bgPr><a:blipFill dpi="0" rotWithShape="1"><a:blip r:embed="rId2"><a:lum/></a:blip><a:srcRect/><a:stretch><a:fillRect/></a:stretch></a:blipFill><a:effectLst/></p:bgPr></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr><p:sp><p:nvSpPr><p:cNvPr id="4" name="CuadroTexto 3"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="2701636" y="1249854"/><a:ext cx="14505709" cy="3053139"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/><a:ln w="12700" cap="flat"><a:noFill/><a:miter lim="400000"/></a:ln><a:effectLst/><a:sp3d/></p:spPr><p:style><a:lnRef idx="0"><a:scrgbClr r="0" g="0" b="0"/></a:lnRef><a:fillRef idx="0"><a:scrgbClr r="0" g="0" b="0"/></a:fillRef><a:effectRef idx="0"><a:scrgbClr r="0" g="0" b="0"/></a:effectRef><a:fontRef idx="none"/></p:style><p:txBody><a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="overflow" horzOverflow="overflow" vert="horz" wrap="square" lIns="48766" tIns="48766" rIns="48766" bIns="48766" numCol="1" spcCol="38100" rtlCol="0" anchor="t"><a:spAutoFit/></a:bodyPr><a:lstStyle/><a:p><a:pPr marL="0" marR="0" indent="0" algn="ctr" defTabSz="1300480" rtl="0" fontAlgn="auto" latinLnBrk="0" hangingPunct="0"><a:lnSpc><a:spcPct val="100000"/></a:lnSpc><a:spcBef><a:spcPts val="0"/></a:spcBef><a:spcAft><a:spcPts val="0"/></a:spcAft><a:buClrTx/><a:buSzTx/><a:buFontTx/><a:buNone/><a:tabLst/></a:pPr><a:r><a:rPr lang="en-US" altLang="en-US" sz="9600" dirty="0"><a:solidFill><a:srgbClr val="FFBE00"/></a:solidFill><a:latin typeface="+mj-lt"/></a:rPr><a:t>Old text</a:t></a:r><a:br><a:rPr lang="en-US" altLang="en-US" sz="9600" dirty="0"><a:solidFill><a:srgbClr val="FFBE00"/></a:solidFill><a:latin typeface="+mj-lt"/></a:rPr></a:br><a:r><a:rPr lang="en-US" altLang="en-US" sz="9600" dirty="0" err="1"><a:solidFill><a:srgbClr val="00C8FF"/></a:solidFill><a:latin typeface="+mj-lt"/></a:rPr><a:t>abc</a:t></a:r><a:r><a:rPr lang="en-US" altLang="en-US" sz="9600" dirty="0"><a:solidFill><a:srgbClr val="00C8FF"/></a:solidFill><a:latin typeface="+mj-lt"/></a:rPr><a:t> Xyz</a:t></a:r><a:endParaRPr kumimoji="0" lang="es-ES_tradnl" sz="5400" b="0" i="0" u="none" strike="noStrike" cap="none" spc="0" normalizeH="0" baseline="0" dirty="0"><a:ln><a:noFill/></a:ln><a:solidFill><a:schemeClr val="bg1"/></a:solidFill><a:effectLst/><a:uFillTx/><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/><a:sym typeface="Calibri"/></a:endParaRPr></a:p></p:txBody></p:sp></p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr><p:transition spd="med"/></p:sld>

I want to replace a little text inside slide2.xml from this:

...<a:t>Old text</a:t>...

to this:

...<a:t>New text</a:t>...

when I replace at least 1 letter and convert to .zip the whole folder and then change extension from .zip to .pptx and try to open the file, MS Powerpoint detects an error and tries to repair the file unsuccessfully.

I don't know why is happening this if I only change a few letters or even one letter. I've tried with bash command (sed) and manually with text editor.

Somebody knows how to edit/modify any slideX.xml without corrupting the whole pptx file?

Destroy666
  • 12,350

1 Answers1

2

Instead of zipping the folder again, try editing the .zip file directly with any tool that can do it, e.g. 7-zip (right click on file -> Edit). Note that you need to close the editor fully in order for 7-zip to register the saved changes. That worked for me with LibreOffice.

The reason this method is better is because whatever metadata is stored in the file, it's preserved. And when you create a new .zip, some of .pptx standards may not be followed.

Destroy666
  • 12,350