2018-01-24 00:01:38 +00:00
|
|
|
// http://officeopenxml.com/WPsection.php
|
|
|
|
import { IColumnsAttributes } from "file/document/body/section-properties/columns/columns-attributes";
|
|
|
|
import { IPageMarginAttributes } from "file/document/body/section-properties/page-margin/page-margin-attributes";
|
|
|
|
import { IPageSizeAttributes } from "file/document/body/section-properties/page-size/page-size-attributes";
|
|
|
|
import { XmlComponent } from "file/xml-components";
|
|
|
|
import { Columns } from "./columns/columns";
|
|
|
|
import { DocumentGrid } from "./doc-grid/doc-grid";
|
|
|
|
import { IDocGridAttributesProperties } from "./doc-grid/doc-grid-attributes";
|
|
|
|
import { PageMargin } from "./page-margin/page-margin";
|
|
|
|
import { PageSize } from "./page-size/page-size";
|
|
|
|
|
|
|
|
export type SectionPropertiesOptions = IPageSizeAttributes & IPageMarginAttributes & IColumnsAttributes & IDocGridAttributesProperties;
|
|
|
|
|
|
|
|
export class SectionProperties extends XmlComponent {
|
2018-01-24 13:09:34 +00:00
|
|
|
constructor(options?: SectionPropertiesOptions) {
|
2018-01-24 00:01:38 +00:00
|
|
|
super("w:sectPr");
|
|
|
|
|
2018-01-24 13:09:34 +00:00
|
|
|
const defaultOptions = {
|
|
|
|
width: 11906,
|
|
|
|
height: 16838,
|
|
|
|
top: 1440,
|
|
|
|
right: 1440,
|
|
|
|
bottom: 1440,
|
|
|
|
left: 1440,
|
|
|
|
header: 708,
|
|
|
|
footer: 708,
|
|
|
|
gutter: 0,
|
|
|
|
space: 708,
|
|
|
|
linePitch: 360,
|
2018-01-25 01:47:47 +00:00
|
|
|
orientation: "portrait",
|
2018-01-24 13:09:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const mergedOptions = {
|
|
|
|
...defaultOptions,
|
|
|
|
...options,
|
|
|
|
};
|
|
|
|
|
2018-01-25 01:47:47 +00:00
|
|
|
this.root.push(new PageSize(mergedOptions.width, mergedOptions.height, mergedOptions.orientation));
|
2018-01-25 01:21:03 +00:00
|
|
|
this.root.push(new PageMargin(mergedOptions.top, mergedOptions.right, mergedOptions.bottom, mergedOptions.left, mergedOptions.header, mergedOptions.footer, mergedOptions.gutter));
|
|
|
|
this.root.push(new Columns(mergedOptions.space));
|
|
|
|
this.root.push(new DocumentGrid(mergedOptions.linePitch));
|
2018-01-24 00:01:38 +00:00
|
|
|
}
|
|
|
|
}
|