2019-02-26 22:20:20 +00:00
|
|
|
// Example on how to add hyperlinks to websites
|
2018-12-24 16:50:53 +00:00
|
|
|
// Import from 'docx' rather than '../build' if you install from npm
|
|
|
|
import * as fs from "fs";
|
2019-01-03 20:47:00 +00:00
|
|
|
import { Document, Packer, Paragraph } from "../build";
|
|
|
|
|
|
|
|
const doc = new Document();
|
2019-06-17 01:51:57 +01:00
|
|
|
const paragraph = new Paragraph({});
|
2019-01-03 20:47:00 +00:00
|
|
|
const link = doc.createHyperlink("http://www.example.com", "Hyperlink");
|
2018-12-24 16:50:53 +00:00
|
|
|
|
|
|
|
paragraph.addHyperLink(link);
|
2019-06-25 23:17:56 +01:00
|
|
|
doc.add(paragraph);
|
2018-12-24 16:50:53 +00:00
|
|
|
|
|
|
|
const packer = new Packer();
|
|
|
|
|
|
|
|
packer.toBuffer(doc).then((buffer) => {
|
|
|
|
fs.writeFileSync("My Document.docx", buffer);
|
|
|
|
});
|