PageHorizontalAlignment
内容
[
隐藏
]HtmlFixedSaveOptions.PageHorizontalAlignment property
指定 HTML 文档中页面的水平对齐方式。 默认值为Center.
public HtmlFixedPageHorizontalAlignment PageHorizontalAlignment { get; set; }
例子
演示将文档保存为 HTML 时如何设置页面的水平对齐方式。
Document doc = new Document(MyDir + "Rendering.docx");
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
{
PageHorizontalAlignment = pageHorizontalAlignment
};
doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.HorizontalAlignment.html", htmlFixedSaveOptions);
string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.HorizontalAlignment/styles.css");
switch (pageHorizontalAlignment)
{
case HtmlFixedPageHorizontalAlignment.Center:
Assert.True(Regex.Match(outDocContents,
"[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt auto; overflow:hidden; }").Success);
break;
case HtmlFixedPageHorizontalAlignment.Left:
Assert.True(Regex.Match(outDocContents,
"[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt 10pt; overflow:hidden; }").Success);
break;
case HtmlFixedPageHorizontalAlignment.Right:
Assert.True(Regex.Match(outDocContents,
"[.]awpage { position:relative; border:solid 1pt black; margin:10pt 10pt 10pt auto; overflow:hidden; }").Success);
break;
}