Make hyperlinks declarative
This commit is contained in:
@ -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")],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
Reference in New Issue
Block a user