我使用以下页面作为示例来生成 docx。 https://github.com/dolanmiu/docx/blob/master/docs/usage/numbering.md
(docx)
PRE-DECLARATIONS
1. Previous Wills & Codicils
I revoke all previous wills and codicils.
2. Marital Status
然后使用 NativeDocuments 的 serverless 功能将 docx 转换为 pdf。 https://github.com/NativeDocuments/docx-to-pdf-on-AWS-Lambda
(生成的pdf)
PRE-DECLARATIONS
Previous Wills & Codicils
I revoke all previous wills and codicils.
Marital Status
以下是我用来生成编号列表的js代码
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent(720, 260));
abstractNum.createLevel(1, "decimal", "%2.", "start").addParagraphProperty(new Indent(1440, 980));
abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addParagraphProperty(new Indent(2160, 1700));
const concrete = numbering.createConcreteNumbering(abstractNum);
doc.createParagraph('Previous Wills & Codicils').setNumbering(concrete, 0);
const packer = new Packer(doc, undefined, undefined, numbering);