ExportEmbeddedCss

HtmlFixedSaveOptions.ExportEmbeddedCss property

Especifica si la CSS (hoja de estilo en cascada) debe incrustarse en el documento HTML.

public bool ExportEmbeddedCss { get; set; }

Ejemplos

Muestra cómo determinar dónde almacenar las hojas de estilo CSS al exportar un documento a HTML.

Document doc = new Document(MyDir + "Rendering.docx");

// Cuando exportamos un documento a html, Aspose.Words también creará una hoja de estilos CSS para formatear el documento.
// Al establecer el indicador "ExportEmbeddedCss" en "verdadero", se guarda la hoja de estilo CSS en un archivo .css.
// y vincular al archivo desde el documento html usando un elemento <link>.
// Establecer el indicador en "falso" incrustará la hoja de estilo CSS dentro del documento HTML,
// que creará solo un archivo en lugar de dos.
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
{
    ExportEmbeddedCss = exportEmbeddedCss
};

doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedCss.html", htmlFixedSaveOptions);

string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedCss.html");

if (exportEmbeddedCss)
{
    Assert.True(Regex.Match(outDocContents, "<style type=\"text/css\">").Success);
    Assert.False(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedCss/styles.css"));
}
else
{
    Assert.True(Regex.Match(outDocContents,
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"HtmlFixedSaveOptions[.]ExportEmbeddedCss/styles[.]css\" media=\"all\" />").Success);
    Assert.True(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedCss/styles.css"));
}

Ver también