Interface IPageSavingCallback
Contents
[
Hide
]IPageSavingCallback interface
Represents a callback that is called when each page in multi page document is saved to a separate stream.
public interface IPageSavingCallback
Methods
Name | Description |
---|---|
OnFinish() | Method which will be called when all pages are written. |
PageSaving(PageSavingArgs) | The method to be called when a page is saved to a stream. |
Examples
Shows how to save multi page document to user-provided streams using page saving callback.
[Test]
public void UsePageSavingCallbackToSavePageToSeparateStreams()
{
var project = new Project(DataDir + "Homemoveplan.mpp");
var imageSaveOptions = new ImageSaveOptions(SaveFileFormat.Png);
var callback = new CustomPageSavingCallback();
imageSaveOptions.PageSavingCallback = callback;
imageSaveOptions.RenderToSinglePage = false;
project.Save(Stream.Null, imageSaveOptions);
foreach (var streams in callback.PageStreams)
{
// process each page stream
}
}
private sealed class CustomPageSavingCallback : IPageSavingCallback
{
public List<MemoryStream> PageStreams { get; } = new List<MemoryStream>();
public void PageSaving(PageSavingArgs args)
{
var memoryStream = new MemoryStream();
args.Stream = memoryStream;
args.KeepStreamOpen = false;
this.PageStreams.Add(memoryStream);
}
public void OnFinish()
{
}
}
See Also
- namespace Aspose.Tasks.Saving
- assembly Aspose.Tasks