Class HtmlSaveOptions

Class HtmlSaveOptions

Nombre del espacio: Aspose.Note.Saving Asamblea: Aspose.Note.dll (25.4.0)

Permite especificar opciones adicionales al almacenar un documento en formato HTML.

public class HtmlSaveOptions : SaveOptions

Inheritance

object SaveOptions HtmlSaveOptions

Miembros heredados

SaveOptions.SaveFormat ,y, SaveOptions.FontsSubsystem ,y, SaveOptions.PageIndex ,y, SaveOptions.PageCount ,y, object.GetType() ,y, object.MemberwiseClone() ,y, object.ToString() ,y, object.Equals(object?) ,y, object.Equals(object?, object?) ,y, object.ReferenceEquals(object?, object?) ,y, object.GetHashCode()

Examples

Mostra cómo guardar un documento en formato html al almacenar todos los recursos (css/fonts/images) en un archivo separado.

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 cómo guardar un documento en un flujo en formato html con la incorporación de todos los recursos (css/fonts/images).

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 cómo crear un documento y guardar en formato html una gama especificada de páginas.

// 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 cómo guardar un documento en formato html con el almacenamiento de todos los recursos (css/fonts/images) utilizando llamadas definidas por el usuario.

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

Obtenga o establece si el archivo StyleSheet se generará para cada nueva página por separado.

public bool CssPerPageGeneration { get; set; }

Valor de la propiedad

bool

CssSavingCallback

Obtenga o establece el llamamiento que se llama a crear recursos para almacenar CSS.

public ICssSavingCallback CssSavingCallback { get; set; }

Valor de la propiedad

ICssSavingCallback

Examples

Mostra cómo guardar un documento en formato html con el almacenamiento de todos los recursos (css/fonts/images) utilizando llamadas definidas por el usuario.

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

Obtenga o establece un valor que indica si el documento por generación de página está activado.

public bool DocumentPerPageGeneration { get; set; }

Valor de la propiedad

bool

ExportCss

Obtenga o establece la forma en que se exporta CSS.

public ResourceExportType ExportCss { get; set; }

Valor de la propiedad

ResourceExportType

Examples

Mostra cómo guardar un documento en formato html al almacenar todos los recursos (css/fonts/images) en un archivo separado.

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 cómo guardar un documento en un flujo en formato html con la incorporación de todos los recursos (css/fonts/images).

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

Obtenga o establece la forma en que se exportan las fuentes.

public ResourceExportType ExportFonts { get; set; }

Valor de la propiedad

ResourceExportType

Examples

Mostra cómo guardar un documento en formato html al almacenar todos los recursos (css/fonts/images) en un archivo separado.

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 cómo guardar un documento en un flujo en formato html con la incorporación de todos los recursos (css/fonts/images).

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

Obtenga o establece la forma en que se exportan las imágenes.

public ResourceExportType ExportImages { get; set; }

Valor de la propiedad

ResourceExportType

Examples

Mostra cómo guardar un documento en formato html al almacenar todos los recursos (css/fonts/images) en un archivo separado.

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 cómo guardar un documento en un flujo en formato html con la incorporación de todos los recursos (css/fonts/images).

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

Obtenga o establece los tipos de rostro de la letra.

public FontFaceType FontFaceTypes { get; set; }

Valor de la propiedad

FontFaceType

Examples

Mostra cómo guardar un documento en formato html al almacenar todos los recursos (css/fonts/images) en un archivo separado.

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 cómo guardar un documento en un flujo en formato html con la incorporación de todos los recursos (css/fonts/images).

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 cómo guardar un documento en formato html con el almacenamiento de todos los recursos (css/fonts/images) utilizando llamadas definidas por el usuario.

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

Obtenga o establece el llamamiento que se llama a crear un recurso para almacenar la letra.

public IFontSavingCallback FontSavingCallback { get; set; }

Valor de la propiedad

IFontSavingCallback

Examples

Mostra cómo guardar un documento en formato html con el almacenamiento de todos los recursos (css/fonts/images) utilizando llamadas definidas por el usuario.

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

Obtenga o establece el llamamiento que se llama a crear un recurso para almacenar la imagen.

public IImageSavingCallback ImageSavingCallback { get; set; }

Valor de la propiedad

IImageSavingCallback

Examples

Mostra cómo guardar un documento en formato html con el almacenamiento de todos los recursos (css/fonts/images) utilizando llamadas definidas por el usuario.

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

Obtenga o establece el llamamiento que se llama a crear recursos para almacenar la página.

public IPageSavingCallback PageSavingCallback { get; set; }

Valor de la propiedad

IPageSavingCallback

 Español