Class HtmlSaveOptions
Namespace: Aspose.Note.Saving
Assembly: Aspose.Note.dll (24.12.0)
Allows to specify additional options when saving document to HTML format.
public class HtmlSaveOptions : SaveOptions
Inheritance
object ← SaveOptions ← HtmlSaveOptions
Inherited Members
SaveOptions.SaveFormat, SaveOptions.FontsSubsystem, SaveOptions.PageIndex, SaveOptions.PageCount, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.```csharp string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); var document = new Document(Path.Combine(dataDir, “Aspose.one”));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).```csharp
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
Shows how to create a document and save in html format specified range of pages.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
Shows how to save a document in html format with storing all resources(css/fonts/images) by using user-defined callbacks.```csharp
// The code below creates 'documentFolder' folder containing document.html, 'css' folder with 'style.css' file, 'images' folder with images and 'fonts' folder with fonts.
// 'style.css' file will contain at the end the following string "/* This line is appended to stream manually by user */"
var savingCallbacks = new UserSavingCallbacks()
{
RootFolder = "documentFolder",
CssFolder = "css",
KeepCssStreamOpened = true,
ImagesFolder = "images",
FontsFolder = "fonts"
};
var options = new HtmlSaveOptions
{
FontFaceTypes = FontFaceType.Ttf,
CssSavingCallback = savingCallbacks,
FontSavingCallback = savingCallbacks,
ImageSavingCallback = savingCallbacks
};
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
Constructors
HtmlSaveOptions()
public HtmlSaveOptions()
Properties
CssPerPageGeneration
Gets or sets whether the StyleSheet file will be generated for each new page separately.
public bool CssPerPageGeneration { get; set; }
Property Value
CssSavingCallback
Gets or sets the callback that is called to create resource to store CSS.
public ICssSavingCallback CssSavingCallback { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) by using user-defined callbacks.```csharp // The code below creates ‘documentFolder’ folder containing document.html, ‘css’ folder with ‘style.css’ file, ‘images’ folder with images and ‘fonts’ folder with fonts. // ‘style.css’ file will contain at the end the following string “/* This line is appended to stream manually by user */” var savingCallbacks = new UserSavingCallbacks() { RootFolder = “documentFolder”, CssFolder = “css”, KeepCssStreamOpened = true, ImagesFolder = “images”, FontsFolder = “fonts” }; var options = new HtmlSaveOptions { FontFaceTypes = FontFaceType.Ttf, CssSavingCallback = savingCallbacks, FontSavingCallback = savingCallbacks, ImageSavingCallback = savingCallbacks };
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
### <a id="Aspose_Note_Saving_HtmlSaveOptions_DocumentPerPageGeneration"></a> DocumentPerPageGeneration
Gets or sets a value indicating whether document per page generation is enabled.
```csharp
public bool DocumentPerPageGeneration { get; set; }
Property Value
ExportCss
Gets or sets the way css is exported.
public ResourceExportType ExportCss { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.```csharp string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); var document = new Document(Path.Combine(dataDir, “Aspose.one”));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).```csharp
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
ExportFonts
Gets or sets the way fonts are exported.
public ResourceExportType ExportFonts { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.```csharp string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); var document = new Document(Path.Combine(dataDir, “Aspose.one”));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).```csharp
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
ExportImages
Gets or sets the way images are exported.
public ResourceExportType ExportImages { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.```csharp string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); var document = new Document(Path.Combine(dataDir, “Aspose.one”));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).```csharp
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
FontFaceTypes
Gets or sets the font face types.
public FontFaceType FontFaceTypes { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.```csharp string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); var document = new Document(Path.Combine(dataDir, “Aspose.one”));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).```csharp
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
Shows how to save a document in html format with storing all resources(css/fonts/images) by using user-defined callbacks.```csharp // The code below creates ‘documentFolder’ folder containing document.html, ‘css’ folder with ‘style.css’ file, ‘images’ folder with images and ‘fonts’ folder with fonts. // ‘style.css’ file will contain at the end the following string “/* This line is appended to stream manually by user */” var savingCallbacks = new UserSavingCallbacks() { RootFolder = “documentFolder”, CssFolder = “css”, KeepCssStreamOpened = true, ImagesFolder = “images”, FontsFolder = “fonts” }; var options = new HtmlSaveOptions { FontFaceTypes = FontFaceType.Ttf, CssSavingCallback = savingCallbacks, FontSavingCallback = savingCallbacks, ImageSavingCallback = savingCallbacks };
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
### <a id="Aspose_Note_Saving_HtmlSaveOptions_FontSavingCallback"></a> FontSavingCallback
Gets or sets the callback that is called to create resource to store font.
```csharp
public IFontSavingCallback FontSavingCallback { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) by using user-defined callbacks.```csharp // The code below creates ‘documentFolder’ folder containing document.html, ‘css’ folder with ‘style.css’ file, ‘images’ folder with images and ‘fonts’ folder with fonts. // ‘style.css’ file will contain at the end the following string “/* This line is appended to stream manually by user */” var savingCallbacks = new UserSavingCallbacks() { RootFolder = “documentFolder”, CssFolder = “css”, KeepCssStreamOpened = true, ImagesFolder = “images”, FontsFolder = “fonts” }; var options = new HtmlSaveOptions { FontFaceTypes = FontFaceType.Ttf, CssSavingCallback = savingCallbacks, FontSavingCallback = savingCallbacks, ImageSavingCallback = savingCallbacks };
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
### <a id="Aspose_Note_Saving_HtmlSaveOptions_ImageSavingCallback"></a> ImageSavingCallback
Gets or sets the callback that is called to create resource to store image.
```csharp
public IImageSavingCallback ImageSavingCallback { get; set; }
Property Value
Examples
Shows how to save a document in html format with storing all resources(css/fonts/images) by using user-defined callbacks.```csharp // The code below creates ‘documentFolder’ folder containing document.html, ‘css’ folder with ‘style.css’ file, ‘images’ folder with images and ‘fonts’ folder with fonts. // ‘style.css’ file will contain at the end the following string “/* This line is appended to stream manually by user */” var savingCallbacks = new UserSavingCallbacks() { RootFolder = “documentFolder”, CssFolder = “css”, KeepCssStreamOpened = true, ImagesFolder = “images”, FontsFolder = “fonts” }; var options = new HtmlSaveOptions { FontFaceTypes = FontFaceType.Ttf, CssSavingCallback = savingCallbacks, FontSavingCallback = savingCallbacks, ImageSavingCallback = savingCallbacks };
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
### <a id="Aspose_Note_Saving_HtmlSaveOptions_PageSavingCallback"></a> PageSavingCallback
Gets or sets the callback that is called to create resource to store page.
```csharp
public IPageSavingCallback PageSavingCallback { get; set; }