add line numbers to section
This commit is contained in:
@ -0,0 +1 @@
|
||||
export * from "./line-number";
|
@ -0,0 +1,38 @@
|
||||
// http://officeopenxml.com/WPsectionLineNumbering.php
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
export enum LineNumberRestartFormat {
|
||||
CONTINUOUS = "continuous",
|
||||
NEW_SECTION = "newSection",
|
||||
NEW_PAGE = "newPage",
|
||||
}
|
||||
|
||||
export interface ILineNumberAttributes {
|
||||
readonly lineNumberCountBy?: number;
|
||||
readonly lineNumberStart?: number;
|
||||
readonly lineNumberRestart?: LineNumberRestartFormat;
|
||||
readonly lineNumberDistance?: number;
|
||||
}
|
||||
|
||||
export class LineNumberAttributes extends XmlAttributeComponent<ILineNumberAttributes> {
|
||||
protected readonly xmlKeys = {
|
||||
lineNumberCountBy: "w:countBy",
|
||||
lineNumberStart: "w:start",
|
||||
lineNumberRestart: "w:restart",
|
||||
lineNumberDistance: "w:distance",
|
||||
};
|
||||
}
|
||||
|
||||
export class LineNumberType extends XmlComponent {
|
||||
constructor(countBy?: number, start?: number, restart?: LineNumberRestartFormat, dist?: number) {
|
||||
super("w:lnNumType");
|
||||
this.root.push(
|
||||
new LineNumberAttributes({
|
||||
lineNumberCountBy: countBy,
|
||||
lineNumberStart: start,
|
||||
lineNumberRestart: restart,
|
||||
lineNumberDistance: dist,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import { IPageBordersOptions, PageBorders } from "./page-border";
|
||||
import { PageMargin } from "./page-margin/page-margin";
|
||||
import { IPageMarginAttributes } from "./page-margin/page-margin-attributes";
|
||||
import { IPageNumberTypeAttributes, PageNumberType } from "./page-number";
|
||||
import { ILineNumberAttributes, LineNumberType } from "./line-number";
|
||||
import { PageSize } from "./page-size/page-size";
|
||||
import { IPageSizeAttributes, PageOrientation } from "./page-size/page-size-attributes";
|
||||
import { TitlePage } from "./title-page/title-page";
|
||||
@ -44,6 +45,7 @@ export type SectionPropertiesOptions = IPageSizeAttributes &
|
||||
IHeadersOptions &
|
||||
IFootersOptions &
|
||||
IPageNumberTypeAttributes &
|
||||
ILineNumberAttributes &
|
||||
IPageBordersOptions &
|
||||
ITitlePageOptions;
|
||||
|
||||
@ -71,6 +73,10 @@ export class SectionProperties extends XmlComponent {
|
||||
footers,
|
||||
pageNumberFormatType,
|
||||
pageNumberStart,
|
||||
lineNumberCountBy,
|
||||
lineNumberStart,
|
||||
lineNumberRestart,
|
||||
lineNumberDistance,
|
||||
pageBorders,
|
||||
pageBorderTop,
|
||||
pageBorderRight,
|
||||
@ -92,6 +98,10 @@ export class SectionProperties extends XmlComponent {
|
||||
this.root.push(new PageNumberType(pageNumberStart, pageNumberFormatType));
|
||||
}
|
||||
|
||||
if (lineNumberCountBy || lineNumberStart || lineNumberRestart || lineNumberDistance) {
|
||||
this.root.push(new LineNumberType(lineNumberCountBy, lineNumberStart, lineNumberRestart, lineNumberDistance));
|
||||
}
|
||||
|
||||
if (pageBorders || pageBorderTop || pageBorderRight || pageBorderBottom || pageBorderLeft) {
|
||||
this.root.push(
|
||||
new PageBorders({
|
||||
|
Reference in New Issue
Block a user