HtmlSaveOptionsExportPageSetup Property

Specifies whether page setup is exported to HTML, MHTML or EPUB. Default is false.

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public bool ExportPageSetup { get; set; }

Property Value

Type: Boolean
Remarks

Each Section in Aspose.Words document model provides page setup information via PageSetup class. When you export a document to HTML format you might need to keep this information for further usage. In particular, page setup might be important for rendering to paged media (printing) or subsequent conversion to the native Microsoft Word file formats (DOCX, DOC, RTF, WML).

In most cases HTML is intended for viewing in browsers where pagination is not performed. So this feature is inactive by default.

Examples
Shows how to preserve section structure/page setup information when saving to html.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Use a DocumentBuilder to insert two sections with text
builder.Writeln("Section 1");
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.Writeln("Section 2");

// Change dimensions and paper size of first section
PageSetup pageSetup = doc.Sections[0].PageSetup;
pageSetup.TopMargin = 36.0;
pageSetup.BottomMargin = 36.0;
pageSetup.PaperSize = PaperSize.A5;

// Section structure and pagination are normally lost when when converting to .html
// We can create an HtmlSaveOptions object with the ExportPageSetup flag set to true
// to preserve the section structure in <div> tags and page dimensions in the output document's CSS
HtmlSaveOptions options = new HtmlSaveOptions
{
    ExportPageSetup = true,
    PrettyFormat = true
};

doc.Save(ArtifactsDir + "HtmlSaveOptions.ExportPageSetup.html", options);
See Also