Fix linting and spelling
This commit is contained in:
@ -4,19 +4,18 @@ import * as fs from "fs";
|
|||||||
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
|
||||||
|
|
||||||
const columnWidth = TabStopPosition.MAX / 4;
|
const columnWidth = TabStopPosition.MAX / 4;
|
||||||
const reciptTabStops = [
|
const receiptTabStops = [
|
||||||
// no need to define first left tab column
|
// no need to define first left tab column
|
||||||
// the right aligned tab column position should point to the end of column
|
// the right aligned tab column position should point to the end of column
|
||||||
// i.e. in this case
|
// i.e. in this case
|
||||||
// (end position of 1st) + (end position of current)
|
// (end position of 1st) + (end position of current)
|
||||||
// columnWidth + columnWidth = columnWidth * 2
|
// columnWidth + columnWidth = columnWidth * 2
|
||||||
|
|
||||||
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
||||||
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
||||||
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }
|
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
||||||
], twoTabStops = [
|
],
|
||||||
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }
|
twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||||
];
|
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
sections: [
|
sections: [
|
||||||
@ -25,62 +24,57 @@ const doc = new Document({
|
|||||||
children: [
|
children: [
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
heading: HeadingLevel.HEADING_1,
|
heading: HeadingLevel.HEADING_1,
|
||||||
children: [ new TextRun("Recipt 001")],
|
children: [new TextRun("Receipt 001")],
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: twoTabStops,
|
tabStops: twoTabStops,
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: "To Bob.\tBy Alice.",
|
text: "To Bob.\tBy Alice.",
|
||||||
bold: true
|
bold: true,
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: twoTabStops,
|
tabStops: twoTabStops,
|
||||||
children: [
|
children: [new TextRun("Foo Inc\tBar Inc")],
|
||||||
new TextRun("Foo Inc\tBar Inc")
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
new Paragraph({text: ""}),
|
new Paragraph({ text: "" }),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: reciptTabStops,
|
tabStops: receiptTabStops,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: "Item\tPrice\tQuantity\tSub-total",
|
text: "Item\tPrice\tQuantity\tSub-total",
|
||||||
bold: true
|
bold: true,
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: reciptTabStops,
|
tabStops: receiptTabStops,
|
||||||
text: "Item 3\t10\t5\t50",
|
text: "Item 3\t10\t5\t50",
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: reciptTabStops,
|
tabStops: receiptTabStops,
|
||||||
text: "Item 3\t10\t5\t50",
|
text: "Item 3\t10\t5\t50",
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: reciptTabStops,
|
tabStops: receiptTabStops,
|
||||||
text: "Item 3\t10\t5\t50"
|
text: "Item 3\t10\t5\t50",
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
tabStops: reciptTabStops,
|
tabStops: receiptTabStops,
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: "\t\t\tTotal: 200",
|
text: "\t\t\tTotal: 200",
|
||||||
bold: true
|
bold: true,
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const stream = Packer.toStream(doc);
|
const stream = Packer.toStream(doc);
|
||||||
stream.pipe(fs.createWriteStream("My Document.docx"));
|
stream.pipe(fs.createWriteStream("My Document.docx"));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user