private static void ExtractSlide(PresentationDocument srcDoc, int slideNumber, PresentationDocument output) { using var fluentBuilder = new FluentPresentationBuilder(output); try { fluentBuilder.AppendSlides(srcDoc, slideNumber, 1); } catch (PresentationBuilderInternalException dbie) { if (dbie.Message.Contains("{0}")) { throw new PresentationBuilderException(string.Format(dbie.Message, slideNumber)); } throw; } }
private static void BuildPresentation(List <SlideSource> sources, PresentationDocument output) { using var fluentBuilder = new FluentPresentationBuilder(output); var sourceNum = 0; var openSettings = new OpenSettings { AutoSave = false }; foreach (var source in sources) { using var streamDoc = new OpenXmlMemoryStreamDocument(source.PmlDocument); using var doc = streamDoc.GetPresentationDocument(openSettings); try { if (source.KeepMaster) { foreach (var slideMasterPart in doc.PresentationPart.SlideMasterParts) { fluentBuilder.AppendMaster(doc, slideMasterPart); } } fluentBuilder.AppendSlides(doc, source.Start, source.Count); } catch (PresentationBuilderInternalException dbie) { if (dbie.Message.Contains("{0}")) { throw new PresentationBuilderException(string.Format(dbie.Message, sourceNum)); } throw; } sourceNum++; } }