Closed rohitchandalurivt closed 5 years ago
pObj.addText( 'Link to Google' ,{ link:'https://www.google.com/', font_size: 13, color: '#3D87F5'});
Working for me.
The first parameter to addText is the text itself, or in this case the caption of the link.
Please let me know if you need more features because the next version dedicated to docx improvements and features.
Can you try with large link "https://github.com/Telemedicine1/issues?q=is:issue+created:2019-05-12..2019-06-24+is:closed"
and once done if you open the file and try to see the hyperlink of the text the hyper link is empty
The code i used
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('Even add ') pObj.addText('external link', { link: link }) pObj.addText('!');
let out = fs.createWriteStream('example.docx') docx.generate(out)
I think that it's neither the link length nor special characters inside it. First try your link normally in the browser. In your case I got 404 code. I think it's permission problem. I tried long link with public access and it worked just fine.
Did it solve your problem @rohitchandalurivt ?
Environment
node -v
: v10.16.0npm -v
: 6.9.0npm ls officegen
: officegen@0.6.2Steps to Reproduce
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'});
is not providing the link in the doc if the link is small it is providing the link given.
Expected Behavior
The word doc should contain the link given
Actual Behavior
The word doc is providing the element as link but the link is empty.
An example code:
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)