Мне нужно преобразовать шаблон powerpoint из potx в pptx. Как видно здесь: http://www.codeproject.com/Tips/366463/Create-PowerPoint-presentation-using-PowerPoint-te Я пробовал использовать следующий код. Однако полученный pptx-документ недействителен и не может быть открыт Office Powerpoint. Если я пропущу строку newDoc.ChangeDocumentType, то итоговый документ будет действителен, но не будет преобразован в pptx. templateContentBytes - это массив байтов, содержащий содержимое документа potx. И temppath указывает на его локальную версию.OpenXml ChangeDocumentType
using (var stream = new MemoryStream())
{
stream.Write(templateContentBytes, 0, templateContentBytes.Length);
using (var newdoc = PresentationDocument.Open(stream, true))
{
newdoc.ChangeDocumentType(PresentationDocumentType.Presentation);
PresentationPart presentationPart = newdoc.PresentationPart;
presentationPart.PresentationPropertiesPart.AddExternalRelationship(
"http://schemas.openxmlformats.org/officeDocument/2006/" + "relationships/attachedTemplate",
new Uri(tempPath, UriKind.Absolute));
presentationPart.Presentation.Save();
File.WriteAllBytes(tempPathResult, stream.ToArray());