/**
*eachOfLimit(coll, limit, iteratee, callbackopt)
*coll Array | Iterable | AsyncIterable | Object A collection to iterate over データソースに相当する
*limit number The maximum number of async operations at a time 同じバッチでいくつのタスクが実行されているか?
*iteratee AsyncFunction An async function (item, key, callback)
*callback function <optional>
*/
Async.eachLimit(data,10,CreateQRcode,function(err){
<!--これはコールバックである--。>
})})
ステップ2 単語の生成
ライブラリdocxと生成された単語
const docx = require('docx')
const { AlignmentType, BorderStyle, WidthType, VerticalAlign, Document, Packer, Paragraph, Media, Table, TableCell, TableRow } = docx
<!--ただ、ドキュメントの例が必要なのだ--。>
doc = new Document({
title:'テスト文書,
<!--これはスタイルであり、特定の公式文書の上にすることができる---。>
styles:{
paragraphStyles:[
{
id:'title',
paragraph:{
alignment:AlignmentType.CENTER
},
run:{
size:24
}
},
{
id:"left",
paragraph: {
indent: {
left: 1400,
},
},
run: {
size: 20,
family:'
}
},
{
id:'right',
paragraph:{
indent:{
left: 500,
}
},
run:{
size:26
}
}
]
}
})
<!--需要がテーブル表を生成することですので、例としてテーブル---。>
<!--この作品は、各行のtrを生成することである--。>
new TableRow({
children:[
new TableCell({
children:[
new Paragraph(''),
new Paragraph({text: `${item.****}`,style:'left'}),
new Paragraph(''),
new Paragraph({text:`${item.****}`,style:'left'}),
new Paragraph(''),
new Paragraph({text:`${item.****}`,style:'left'}),
new Paragraph(''),
],
<!--width 次のWidthType.PERCENTAGE それはパーセンテージだ--。>
width:{
size: 54,
type: WidthType.PERCENTAGE
},
borders:{
right:{style:BorderStyle.NONE,size:0,color:'ffffff'}
}
}),
new TableCell({
children:[
new Paragraph(''),
new Paragraph(Media.addImage(doc,fs.readFileSync(path.join(QRcodeOutDir, `${item.****}.png`)),120,120)),
<!--この作品は写真に挿入されている--。>
],
<!--width 次のWidthType.PERCENTAGE それはパーセンテージだ--。>
width:{
size: 26,
type: WidthType.PERCENTAGE
},
borders:{
left:{style:BorderStyle.NONE,size:0,color:'ffffff'},
right:{style:BorderStyle.NONE,size:0,color:'ffffff'},
}
}),
new TableCell({
children:[
new Paragraph({text:'****',style:'right'}),
new Paragraph(''),
new Paragraph({text:'****',style:'right'}),
],
<!--width 次のWidthType.PERCENTAGE それはパーセンテージだ--。>
width:{
size: 20,
type: WidthType.PERCENTAGE
},
borders:{
left:{style:BorderStyle.NONE,size:0,color:'ffffff'}
},
verticalAlign:VerticalAlign.CENTER,
})
],
})
<!--各行を行の配列に入れることができる---。>
<!--この作品は、直接テーブルの行の値に割り当てられている--?>
const table = new Table({
rows:rows
})
doc.addSection({
children:[
<!--この作品では、コンテンツを追加する必要があるものに加えて、表に加えて単語である---。>
new Paragraph({text:'****',style:'title'}),
table
]
})
<!--最後に、単語を生成する出力パスによると--。>
Packer.toBuffer(doc).then((buffer)=>{
fs.writeFileSync(path.join(wordOutDir, `${wordInfos.taskName}.docx`),buffer)
})