Numbering levels do not apply when called as instance methods (static required)
See original GitHub issueNumbering does not appear to be responding to what is defined in createLevel
method. See the screenshot below, which is generated by the code that follows.
Adjusting the indent levels or list type (e.g. upperRoman
vs decimal
) in createLevel()
has no effect. I tested this in three different ways, commented as OPTION 1
, OPTION 2
, OPTION 3
in the code below. In each option the output looks the same.
var fs = require('fs')
var docx = require('docx');
const doc = new docx.Document();
const numbering = new docx.Numbering();
const abstractNum = numbering.createAbstractNumbering();
// OPTION 1: No createLevel
// OPTION 2:
// abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new docx.Indent(360, 130));
// abstractNum.createLevel(1, "decimal", "%2", "start").addParagraphProperty(new docx.Indent(1200, 3000));
// abstractNum.createLevel(2, "lowerLetter", "%3 ", "start").addParagraphProperty(new docx.Indent(4000, 5000));
// OPTION 3;
// abstractNum.createLevel(0, "upperRoman", "%1", "start").indent({ left: 360, hanging: 130 });
// abstractNum.createLevel(1, "decimal", "%1.%2.", "start").indent({ left: 1200, hanging: 3000 });
// abstractNum.createLevel(2, "lowerLetter", "%3)", "start").indent({ left: 4000, hanging: 5000 });
const concrete = numbering.createConcreteNumbering(abstractNum);
doc.addSection({
children: [
new docx.Paragraph({ text: "Item 1", numbering: { num: concrete, level: 0 }}),
new docx.Paragraph({ text: "Item 1.1", numbering: { num: concrete, level: 1 }}),
new docx.Paragraph({ text: "Item 1.2", numbering: { num: concrete, level: 1 }}),
new docx.Paragraph({ text: "Item 1.2.1", numbering: { num: concrete, level: 2 }}),
new docx.Paragraph({ text: "Item 1.2.2", numbering: { num: concrete, level: 2 }}),
new docx.Paragraph({ text: "Item 1.2.3", numbering: { num: concrete, level: 2 }}),
new docx.Paragraph({ text: "Item 1.3", numbering: { num: concrete, level: 1 }}),
new docx.Paragraph({ text: "Item 2", numbering: { num: concrete, level: 0 }}),
new docx.Paragraph({ text: "Item 3", numbering: { num: concrete, level: 0 }}),
],
});
docx.Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("docx-simple-num.docx", buffer);
});
Using docx version 5.0.0-rc5
and Node v10.16.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Python's Instance, Class, and Static Methods Demystified
This tutorial helps demystify what's behind class, static, and instance methods in Python.
Read more >Static methods vs Instance methods in Java - GeeksforGeeks
Instance method (s) belong to the Object of the class, not to the class i.e. they can be called after creating the Object...
Read more >4. Static Variables and Static Methods - Essential ActionScript ...
Static methods have two limitations that instance methods do not. First, a class method cannot use the this keyword. Second, a static method...
Read more >Python Methods: Instance, Static and Class - The Teclado Blog
In this blog post we are going to explain what types of methods exist, how they work, and how they are different from...
Read more >Performance of static methods vs instance methods
When keeping state is not a concern (no fields or properties are required), is it always better to use a static class? Where...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
EDIT: This comment has been moved to a separate issue, #396.
Perhaps this is a separate issue, but in the interest of not flooding the issues list I tack it on here: paragraphs with
numbering
defined do not respond tostyle
. See the example below, followed by the code that generated it.Code:
API is now changed, please refer to:
https://github.com/dolanmiu/docx/blob/master/demo/3-numbering-and-bullet-points.ts https://github.com/dolanmiu/docx/blob/master/demo/29-numbered-lists.ts https://github.com/dolanmiu/docx/blob/master/demo/2-declaritive-styles.ts