Class HtmlSaveOptions

Class HtmlSaveOptions

Il nome: Aspose.Note.Saving Assemblea: Aspose.Note.dll (25.4.0)

Permette di specificare ulteriori opzioni quando si salva il documento in formato HTML.

public class HtmlSaveOptions : SaveOptions

Inheritance

object SaveOptions HtmlSaveOptions

I membri ereditari

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

Mostra come salvare un documento in formato html memorizzando tutte le risorse (css/fonti/immagini) in un file separato.

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);

Mostra come salvare un documento in un flusso in formato html con l’integrazione di tutte le risorse (css/fonti/immagini).

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);

Mostra come creare un documento e salvare in formato html una gamma specifica di pagine.

// 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
                                                                                                             });

Mostra come salvare un documento in formato html con il salvataggio di tutte le risorse (css/fonti/immagini) utilizzando callbacks definiti dall’utente.

// 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

Riceve o impone se il file StyleSheet sarà generato per ogni nuova pagina separatamente.

public bool CssPerPageGeneration { get; set; }

Valore di proprietà

bool

CssSavingCallback

Riceve o impone il callback che viene chiamato per creare una risorsa per memorizzare CSS.

public ICssSavingCallback CssSavingCallback { get; set; }

Valore di proprietà

ICssSavingCallback

Examples

Mostra come salvare un documento in formato html con il salvataggio di tutte le risorse (css/fonti/immagini) utilizzando callbacks definiti dall’utente.

// 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 */");
                                                                                                                                    }

DocumentPerPageGeneration

Riceve o impone un valore che indica se il documento per generazione di pagina è attivato.

public bool DocumentPerPageGeneration { get; set; }

Valore di proprietà

bool

ExportCss

Ottieni o imponi il modo in cui viene esportato il css.

public ResourceExportType ExportCss { get; set; }

Valore di proprietà

ResourceExportType

Examples

Mostra come salvare un documento in formato html memorizzando tutte le risorse (css/fonti/immagini) in un file separato.

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);

Mostra come salvare un documento in un flusso in formato html con l’integrazione di tutte le risorse (css/fonti/immagini).

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

Riceve o impone il modo in cui vengono esportate le font.

public ResourceExportType ExportFonts { get; set; }

Valore di proprietà

ResourceExportType

Examples

Mostra come salvare un documento in formato html memorizzando tutte le risorse (css/fonti/immagini) in un file separato.

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);

Mostra come salvare un documento in un flusso in formato html con l’integrazione di tutte le risorse (css/fonti/immagini).

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

Riceve o impone il modo in cui le immagini vengono esportate.

public ResourceExportType ExportImages { get; set; }

Valore di proprietà

ResourceExportType

Examples

Mostra come salvare un documento in formato html memorizzando tutte le risorse (css/fonti/immagini) in un file separato.

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);

Mostra come salvare un documento in un flusso in formato html con l’integrazione di tutte le risorse (css/fonti/immagini).

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

Riceve o impone i tipi di faccia della font.

public FontFaceType FontFaceTypes { get; set; }

Valore di proprietà

FontFaceType

Examples

Mostra come salvare un documento in formato html memorizzando tutte le risorse (css/fonti/immagini) in un file separato.

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);

Mostra come salvare un documento in un flusso in formato html con l’integrazione di tutte le risorse (css/fonti/immagini).

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);

Mostra come salvare un documento in formato html con il salvataggio di tutte le risorse (css/fonti/immagini) utilizzando callbacks definiti dall’utente.

// 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 */");
                                                                                                                                    }

FontSavingCallback

Riceve o impone il callback che viene chiamato per creare una risorsa per memorizzare la font.

public IFontSavingCallback FontSavingCallback { get; set; }

Valore di proprietà

IFontSavingCallback

Examples

Mostra come salvare un documento in formato html con il salvataggio di tutte le risorse (css/fonti/immagini) utilizzando callbacks definiti dall’utente.

// 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 */");
                                                                                                                                    }

ImageSavingCallback

Riceve o impone il callback che viene chiamato per creare una risorsa per memorizzare l’immagine.

public IImageSavingCallback ImageSavingCallback { get; set; }

Valore di proprietà

IImageSavingCallback

Examples

Mostra come salvare un documento in formato html con il salvataggio di tutte le risorse (css/fonti/immagini) utilizzando callbacks definiti dall’utente.

// 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 */");
                                                                                                                                    }

PageSavingCallback

Riceve o impone il callback che viene chiamato per creare una risorsa per memorizzare la pagina.

public IPageSavingCallback PageSavingCallback { get; set; }

Valore di proprietà

IPageSavingCallback

 Italiano