feature: add support for section page borders

This commit is contained in:
Igor Bulovski
2018-07-03 13:48:31 +02:00
parent 612a2f90ac
commit 796e000826
11 changed files with 261 additions and 34 deletions

View File

@ -10,7 +10,7 @@ import { PageMargin } from "./page-margin/page-margin";
import { IPageMarginAttributes } from "./page-margin/page-margin-attributes";
import { PageSize } from "./page-size/page-size";
import { IPageSizeAttributes, PageOrientation } from "./page-size/page-size-attributes";
import { FooterReferenceType, IPageNumberTypeAttributes, PageNumberType, PageNumberFormat } from ".";
import { FooterReferenceType, IPageNumberTypeAttributes, PageNumberType, PageNumberFormat, PageBordersOptions, PageBorders } from ".";
import { HeaderReferenceType } from "./header-reference/header-reference-attributes";
export type SectionPropertiesOptions = IPageSizeAttributes &
@ -19,7 +19,8 @@ export type SectionPropertiesOptions = IPageSizeAttributes &
IDocGridAttributesProperties &
HeaderOptions &
FooterOptions &
IPageNumberTypeAttributes;
IPageNumberTypeAttributes &
PageBordersOptions;
export class SectionProperties extends XmlComponent {
private options: SectionPropertiesOptions;
@ -45,6 +46,11 @@ export class SectionProperties extends XmlComponent {
footerId: 0,
pageNumberStart: undefined,
pageNumberFormatType: PageNumberFormat.DECIMAL,
pageBorders: undefined,
pageBorderTop: undefined,
pageBorderRight: undefined,
pageBorderBottom: undefined,
pageBorderLeft: undefined,
};
const mergedOptions = {
@ -81,6 +87,24 @@ export class SectionProperties extends XmlComponent {
this.root.push(new PageNumberType(mergedOptions.pageNumberStart, mergedOptions.pageNumberFormatType));
if (
mergedOptions.pageBorders ||
mergedOptions.pageBorderTop ||
mergedOptions.pageBorderRight ||
mergedOptions.pageBorderBottom ||
mergedOptions.pageBorderLeft
) {
this.root.push(
new PageBorders({
pageBorders: mergedOptions.pageBorders,
pageBorderTop: mergedOptions.pageBorderTop,
pageBorderRight: mergedOptions.pageBorderRight,
pageBorderBottom: mergedOptions.pageBorderBottom,
pageBorderLeft: mergedOptions.pageBorderLeft,
}),
);
}
this.options = mergedOptions;
}