Add hyperlink to demo

This commit is contained in:
Dolan Miu
2023-03-05 18:46:02 +00:00
parent 66a1992da0
commit 6ad18420e5

View File

@ -2,6 +2,7 @@
// Import from 'docx' rather than '../build' if you install from npm // Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
ExternalHyperlink,
HeadingLevel, HeadingLevel,
ImageRun, ImageRun,
Paragraph, Paragraph,
@ -39,7 +40,19 @@ patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
}, },
footer_text: { footer_text: {
type: PatchType.PARAGRAPH, type: PatchType.PARAGRAPH,
children: [new TextRun("replaced just as well")], children: [
new TextRun("replaced just as"),
new TextRun(" well"),
new ExternalHyperlink({
children: [
new TextRun({
text: "BBC News Link",
style: "Hyperlink",
}),
],
link: "https://www.bbc.co.uk/news",
}),
],
}, },
image_test: { image_test: {
type: PatchType.PARAGRAPH, type: PatchType.PARAGRAPH,