Class DocumentPartSavingArgs

Class DocumentPartSavingArgs

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.3.0)

Provides data for the Aspose.Words.Saving.IDocumentPartSavingCallback.DocumentPartSaving(Aspose.Words.Saving.DocumentPartSavingArgs) callback.

To learn more, visit the Save a Document documentation article.

public class DocumentPartSavingArgs

Inheritance

objectDocumentPartSavingArgs

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

When Aspose.Words saves a document to HTML or related formats and Aspose.Words.Saving.HtmlSaveOptions.DocumentSplitCriteria is specified, the document is split into parts and by default, each document part is saved into a separate file.

Class Aspose.Words.Saving.DocumentPartSavingArgs allows you to control how each document part will be saved. It allows to redefine how file names are generated or to completely circumvent saving of document parts into files by providing your own stream objects.

To save document parts into streams instead of files, use the Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartStream property.

Properties

Document

Gets the document object that is being saved.

public Document Document { get; }

Property Value

Document

DocumentPartFileName

Gets or sets the file name (without path) where the document part will be saved to.

public string DocumentPartFileName { get; set; }

Property Value

string

Remarks

This property allows you to redefine how the document part file names are generated during export to HTML or EPUB.

When the callback is invoked, this property contains the file name that was generated by Aspose.Words. You can change the value of this property to save the document part into a different file. Note that the file name for each part must be unique.

Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartFileName must contain only the file name without the path. Aspose.Words determines the path for saving using the document file name. If output document file name was not specified, for instance when saving to a stream, this file name is used only for referencing document parts. The same is true when saving to EPUB format.

Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartStream

DocumentPartStream

Allows to specify the stream where the document part will be saved to.

public Stream DocumentPartStream { get; set; }

Property Value

Stream

Remarks

This property allows you to save document parts to streams instead of files during HTML export.

The default value is null. When this property is null, the document part will be saved to a file specified in the Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartFileName property.

When saving to a stream in HTML format is requested by Aspose.Words.Document.Save(System.IO.Stream,Aspose.Words.SaveFormat) or Aspose.Words.Document.Save(System.IO.Stream,Aspose.Words.Saving.SaveOptions) and first document part is about to be saved, Aspose.Words suggests here the main output stream initially passed by the caller.

When saving to EPUB format that is a container format based on HTML, Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartStream cannot be specified because all subsidiary parts will be encapsulated into a single output package.

Aspose.Words.Saving.DocumentPartSavingArgs.KeepDocumentPartStreamOpen

KeepDocumentPartStreamOpen

Specifies whether Aspose.Words should keep the stream open or close it after saving a document part.

public bool KeepDocumentPartStreamOpen { get; set; }

Property Value

bool

Remarks

Default is false and Aspose.Words will close the stream you provided in the Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartStream property after writing a document part into it. Specify true to keep the stream open. Please note that the main output stream provided in the call to Aspose.Words.Document.Save(System.IO.Stream,Aspose.Words.SaveFormat) or Aspose.Words.Document.Save(System.IO.Stream,Aspose.Words.Saving.SaveOptions) will never be closed by Aspose.Words even if Aspose.Words.Saving.DocumentPartSavingArgs.KeepDocumentPartStreamOpen is set to false.

Aspose.Words.Saving.DocumentPartSavingArgs.DocumentPartStream