Word文档无法使用officegen NPM软件包创建带有大型链接的超链接

时间:2019-08-02 01:54:17

标签: npm

我正在尝试使用officegen NPM模块生成带有超链接的Word文档。我能够生成带有超链接较小的单词,但无法生成具有较大URL的链接。当我尝试打开docx时,doc表示恢复文件,我说是,文件显示链接为超级链接,但网址为空。

代码:

const officegen = require('officegen')

const fs = require('fs')
let docx = officegen('docx')
// Officegen calling this function after finishing to generate the docx document:
docx.on('finalize', function(written) {
console.log(
'Finish to create a Microsoft Word document.'
)
})

const link = 'https://github.com/Telemedicine1/issues?utf8=%E2%9C%93&q=is:issue+created:2019-05-12..2019-06-24';

let pObj = docx.createP();
pObj.addText( 'Report',{ bold: true, font_size: 20, color: 'black' });
pObj.addLineBreak ();
pObj.addLineBreak ();
pObj.addText( 'SUMMARY',{ link:'https://github.com/', bold: true, font_size: 14, color: 'black' });
pObj.addLineBreak ();
pObj.addLineBreak ();
pObj.addText( '1) A total of ',{ font_size: 13, color: 'black' });
pObj.addText( '21',{ link: link, font_size: 13, color: 'blue'});
pObj.addText( ' new issues opened last week out which ', { font_size: 13, color: 'black' });
pObj.addText( '8' ,{ link:'https://github.com/Telemedicine1/issues?q=is:issue+created:2019-05-12..2019-06-24+is:closed', font_size: 13, color: '#3D87F5'});
pObj.addText( ' were closed and ',{ font_size: 13, color: 'black' });
pObj.addText( '13' ,{ link:'https://github.com/Telemedicine1/issues?q=is:issue+created:2019-05-12..2019-06-24+is:open', font_size: 13, color: '#3D87F5'});
pObj.addText( ' are still open.',{ font_size: 13, color: 'black' });
pObj.addLineBreak();
pObj.addText( '2) A total of ',{ font_size: 13, color: 'black' });
pObj.addText( '16' ,{ link:'https://github.com/Telemedicine1/issues?utf8=%E2%9C%93&q=is:issue+closed:2019-05-12..2019-06-24+is:closed+', font_size: 13, color: '#3D87F5'});
pObj.addText( ' issues were closed (including bug bash).',{ font_size: 13, color: 'black' });

let out = fs.createWriteStream('example.docx')

docx.generate(out)

0 个答案:

没有答案