ASP.NET to PowerPoint: File gets corrupted when adding image

bibistroc

New Member
I have used this example when exporting data to PowerPoint: I have modified the GenerateSlidesFromDB() method: \[code\]public void GenerateSlidesFromDB() { string slideName = @"C:\Users\x\Desktop\output.pptx"; File.Copy(@"C:\Users\x\Desktop\Test.pptx", slideName, true); using (PresentationDocument presentationDocument = PresentationDocument.Open(slideName, true)) { PresentationPart presentationPart = presentationDocument.PresentationPart; SlidePart slideTemplate = (SlidePart)presentationPart.GetPartById("rId2"); string firstName = "Test User"; SlidePart newSlide = CloneSlidePart(presentationPart, slideTemplate); InsertContent(newSlide, firstName); newSlide.Slide.Save(); DeleteTemplateSlide(presentationPart, slideTemplate); presentationPart.Presentation.Save(); } }\[/code\]As you can see I overwrite the placeholder with "Test User", and it works like a charm.I need to add an image (as a placeholder) to this pptx-file. When I do that (and run the code again) I get a corrupted pptx-file?Error message: \[quote\] PowerPoint removed unreadable content in output.pptx. You should review this presentation to determine whether any content was unexpectedly changed or removed.\[/quote\]Edit: If I try the original code (which is slightly modified since I dont have Adventureworks), I get some other kind of error message:This file may have become corrupt or damaged for the following reasons:Third-party XML editors sometimes create files that are not compatible with Microsoft Office XML specifications.The file has been purposely corrupted with the intent to harm your computer or your data.Be cautious when opening a file from an unknown source.PowerPoint can attempt to recover data from the file, but some presentation data, such as shapes, text,and formatting, may be lost.Do one of the following:If you want to recover data from the file, click Yes.If you do not want to recoverdata from the file, click No.Thanks...
 

davegeeit

New Member
bibistroc said:
I have used this example when exporting data to PowerPoint: I have modified the GenerateSlidesFromDB() method: \[code\]public void GenerateSlidesFromDB() { string slideName = @"C:\Users\x\Desktop\output.pptx"; File.Copy(@"C:\Users\x\Desktop\Test.pptx", slideName, true); using (PresentationDocument presentationDocument = PresentationDocument.Open(slideName, true)) { PresentationPart presentationPart = presentationDocument.PresentationPart; SlidePart slideTemplate = (SlidePart)presentationPart.GetPartById("rId2"); string firstName = "Test User"; SlidePart newSlide = CloneSlidePart(presentationPart, slideTemplate); InsertContent(newSlide, firstName); newSlide.Slide.Save(); DeleteTemplateSlide(presentationPart, slideTemplate); presentationPart.Presentation.Save(); } }\[/code\]As you can see I overwrite the placeholder with "Test User", and it works like a charm.I need to add an image (as a placeholder) to this pptx-file. When I do that (and run the code again) I get a corrupted pptx-file?Error message: \[quote\] PowerPoint removed unreadable content in output.pptx. You should review this presentation to determine whether any content was unexpectedly changed or removed.\[/quote\]Edit: If I try the original code (which is slightly modified since I dont have Adventureworks), I get some other kind of error message:This file may have become corrupt or damaged for the following reasons:Third-party XML editors sometimes create files that are not compatible with Microsoft Office XML specifications.The file has been purposely corrupted with the intent to harm your computer or your data.Be cautious when opening a file from an unknown source.PowerPoint can attempt to recover data from the file, but some presentation data, such as shapes, text,and formatting, may be lost.Do one of the following:If you want to recover data from the file, click Yes.If you do not want to recoverdata from the file, click No.Thanks...

RecoveryFix for Powerpoint has built in sophisticated algorithms that help in quick recovery of project data from corrupt ppt/pptx files. This software allows the user to repair corrupt Powerpoint documents in two modes i.e., integrated mode and standard mode. Integrated mode should be chosen to resolve minor corruption issues of Powerpoint data files. User can select Standard mode of the software to repair highly corrupt ppt/pptx files. This software supports MS Powerpoint 2000, 2003, 2002(XP), 2010 and 2007.

http://www.powerpointrecovery.net/

Thanks
 

davegeeit

New Member
bibistroc said:
I have used this example when exporting data to PowerPoint: I have modified the GenerateSlidesFromDB() method: \[code\]public void GenerateSlidesFromDB() { string slideName = @"C:\Users\x\Desktop\output.pptx"; File.Copy(@"C:\Users\x\Desktop\Test.pptx", slideName, true); using (PresentationDocument presentationDocument = PresentationDocument.Open(slideName, true)) { PresentationPart presentationPart = presentationDocument.PresentationPart; SlidePart slideTemplate = (SlidePart)presentationPart.GetPartById("rId2"); string firstName = "Test User"; SlidePart newSlide = CloneSlidePart(presentationPart, slideTemplate); InsertContent(newSlide, firstName); newSlide.Slide.Save(); DeleteTemplateSlide(presentationPart, slideTemplate); presentationPart.Presentation.Save(); } }\[/code\]As you can see I overwrite the placeholder with "Test User", and it works like a charm.I need to add an image (as a placeholder) to this pptx-file. When I do that (and run the code again) I get a corrupted pptx-file?Error message: \[quote\] PowerPoint removed unreadable content in output.pptx. You should review this presentation to determine whether any content was unexpectedly changed or removed.\[/quote\]Edit: If I try the original code (which is slightly modified since I dont have Adventureworks), I get some other kind of error message:This file may have become corrupt or damaged for the following reasons:Third-party XML editors sometimes create files that are not compatible with Microsoft Office XML specifications.The file has been purposely corrupted with the intent to harm your computer or your data.Be cautious when opening a file from an unknown source.PowerPoint can attempt to recover data from the file, but some presentation data, such as shapes, text,and formatting, may be lost.Do one of the following:If you want to recover data from the file, click Yes.If you do not want to recoverdata from the file, click No.Thanks...

RecoveryFix for Powerpoint has built in sophisticated algorithms that help in quick recovery of project data from corrupt ppt/pptx files. This software allows the user to repair corrupt Powerpoint documents in two modes i.e., integrated mode and standard mode. Integrated mode should be chosen to resolve minor corruption issues of Powerpoint data files. User can select Standard mode of the software to repair highly corrupt ppt/pptx files. This software supports MS Powerpoint 2000, 2003, 2002(XP), 2010 and 2007.

Thanks
 
Top