/// <summary> /// Creates a new instance of the PresentationDocument class from the IO stream. /// </summary> /// <param name="stream">The IO stream on which to create the PresentationDocument.</param> /// <param name="type">The type of the PresentationDocument.</param> /// <param name="autoSave">Whether to auto save the created document.</param> /// <returns>A new instance of PresentationDocument.</returns> /// <exception cref="ArgumentNullException">Thrown when "stream" is null reference.</exception> /// <exception cref="IOException">Thrown when "stream" is not opened with Write access.</exception> public static PresentationDocument Create(Stream stream, PresentationDocumentType type, bool autoSave) { PresentationDocument doc = new PresentationDocument(); doc.DocumentType = type; doc.OpenSettings = new OpenSettings(); doc.OpenSettings.AutoSave = autoSave; doc.MainPartContentType = MainPartContentTypes[type]; doc.CreateCore(stream); return(doc); }
/// <summary> /// Created a new instance of the PresentationDocument class from the specified file. /// </summary> /// <param name="path">The path and file name of the target PresentationDocument.</param> /// <param name="type">The type of the PresentationDocument.</param> /// <param name="autoSave">Whether to auto save the created document.</param> /// <returns>A new instance of PresentationDocument.</returns> /// <exception cref="ArgumentNullException">Thrown when "path" is null reference.</exception> public static PresentationDocument Create(string path, PresentationDocumentType type, bool autoSave) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(path); } PresentationDocument doc = new PresentationDocument(); doc.DocumentType = type; doc.OpenSettings = new OpenSettings(); doc.OpenSettings.AutoSave = autoSave; doc.MainPartContentType = MainPartContentTypes[type]; doc.CreateCore(path); return(doc); }
/// <summary> /// Creates a new instance of the PresentationDocument class from the specified package. /// </summary> /// <param name="package">The specified OpenXml package.</param> /// <param name="type">The type of the PresentationDocument.</param> /// <param name="autoSave">Whether to auto save the created document.</param> /// <returns>A new instance of PresentationDocument.</returns> /// <exception cref="ArgumentNullException">Thrown when "package" is null reference.</exception> /// <exception cref="IOException">Thrown when "package" is not opened with Write access.</exception> public static PresentationDocument Create(Package package, PresentationDocumentType type, bool autoSave) { var doc = new PresentationDocument { DocumentType = type, OpenSettings = new OpenSettings { AutoSave = autoSave }, MainPartContentType = MainPartContentTypes[type], }; doc.CreateCore(package); return(doc); }