PageSavingArgsPageIndex Property |
Namespace: Aspose.Words.Saving
public void PageFileName() { Document doc = new Document(MyDir + "Rendering.docx"); HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions { PageIndex = 0, PageCount = doc.PageCount }; htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); doc.Save($"{ArtifactsDir}SavingCallback.PageFileName.html", htmlFixedSaveOptions); string[] filePaths = Directory.GetFiles(ArtifactsDir, "SavingCallback.PageFileName.Page_*.html"); for (int i = 0; i < doc.PageCount; i++) { string file = $"{ArtifactsDir}SavingCallback.PageFileName.Page_{i}.html"; } } /// <summary> /// Custom PageFileName is specified. /// </summary> private class CustomPageFileNamePageSavingCallback : IPageSavingCallback { public void PageSaving(PageSavingArgs args) { string outFileName = $"{ArtifactsDir}SavingCallback.PageFileName.Page_{args.PageIndex}.html"; // Specify name of the output file for the current page either in this args.PageFileName = outFileName; // ..or by setting up a custom stream args.PageStream = new FileStream(outFileName, FileMode.Create); Assert.False(args.KeepPageStreamOpen); } }