Make hyperlinks declarative

This commit is contained in:
Dolan
2019-12-18 21:11:15 +00:00
parent 2bece0bb61
commit c68dc8c52a
14 changed files with 114 additions and 53 deletions

View File

@ -1,15 +1,21 @@
// Example on how to add hyperlinks to websites
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
import { Document, HyperlinkRef, Packer, Paragraph } from "../build";
const doc = new Document();
const link = doc.createHyperlink("http://www.example.com", "Hyperlink");
const doc = new Document({
hyperlinks: {
myCoolLink: {
link: "http://www.example.com",
text: "Hyperlink",
},
},
});
doc.addSection({
children: [
new Paragraph({
children: [link],
children: [new HyperlinkRef("myCoolLink")],
}),
],
});