Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

⚓ Hyperlink module for docxtemplater

License

NotificationsYou must be signed in to change notification settings

sujith3g/docxtemplater-link-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperlink module fordocxtemplater

Download countghit.meBuild Status

Installation:

You will need docxtemplater v2.1.1:npm install docxtemplater

Install this module:npm install docxtemplater-link-module

Usage: Text and URL

The example below will displays the following hyperlink:

Lorem ipsumdolor sit amet.

Your docx should contain the text:Lorem ipsum {^link} amet..

varfs=require('fs');varcontent=fs.readFileSync(__dirname+"/example-href.docx","binary");varDocxGen=require('docxtemplater');varLinkModule=require('docxtemplater-link-module');varlinkModule=newLinkModule();vardocx=newDocxGen().attachModule(linkModule).load(content).setData({link :{text :"dolor sit",url :"http://google.com"}}).render();varbuffer=docx.getZip().generate({type:"nodebuffer"});fs.writeFile("test.docx",buffer);

Usage: URL only

The example below will displays the following hyperlink:

Lorem ipsumhttp://google.com amet.

Your docx should contain the text:Lorem ipsum {^link} amet..

varfs=require('fs');varcontent=fs.readFileSync(__dirname+"/example-href.docx","binary");varDocxGen=require('docxtemplater');varLinkModule=require('docxtemplater-link-module');varlinkModule=newLinkModule();vardocx=newDocxGen().attachModule(linkModule).load(content).setData({link :"http://google.com"}).render();varbuffer=docx.getZip().generate({type:"nodebuffer"});fs.writeFile("test.docx",buffer);

Usage: Email address support

The example below will displays the following hyperlink:

Lorem ipsumjohn.smith@example.com amet.

Your docx should contain the text:Lorem ipsum {^link} amet..

varfs=require('fs');varcontent=fs.readFileSync(__dirname+"/example-mailto.docx","binary");varDocxGen=require('docxtemplater');varLinkModule=require('docxtemplater-link-module');varlinkModule=newLinkModule();vardocx=newDocxGen().attachModule(linkModule).load(content).setData({link :"john.smith@example.com"}).render();varbuffer=docx.getZip().generate({type:"nodebuffer"});fs.writeFile("test.docx",buffer);

Usage: Text and URL in powerpoint pptx

The example below will displays the following hyperlink powerpoint:

Lorem ipsumdolor sit amet.

Your pptx should contain the text:Lorem ipsum {^link} amet..

varfs=require('fs');varcontent=fs.readFileSync(__dirname+"/example-href.pptx","binary");varDocxGen=require('docxtemplater');varLinkModule=require('docxtemplater-link-module');varlinkModule=newLinkModule();vardocx=newDocxGen().attachModule(linkModule).setOptions({fileType :"pptx"}).load(content).setData({link :{text :"dolor sit",url :"http://google.com"}}).render();varbuffer=docx.getZip().generate({type:"nodebuffer"});fs.writeFile("output-href.pptx",buffer);

Usage: Email address support in powerpoint

The example below will displays the following hyperlink:

Lorem ipsumjohn.smith@example.com amet.

Your pptx should contain the text:Lorem ipsum {^link} amet..

varfs=require('fs');varcontent=fs.readFileSync(__dirname+"/example-mailto.pptx","binary");varDocxGen=require('docxtemplater');varLinkModule=require('docxtemplater-link-module');varlinkModule=newLinkModule();vardocx=newDocxGen().attachModule(linkModule).setOptions({fileType :"pptx"}).load(content).setData({link :"john.smith@example.com"}).render();varbuffer=docx.getZip().generate({type:"nodebuffer"});fs.writeFile("output-mailto.pptx",buffer);

Testing

You can test that everything works fine using the commandmocha. This will also create 2 docx files under the root directory that you can open to check if the docx are correct

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp