diff --git a/demo/35-hyperlinks.ts b/demo/35-hyperlinks.ts index fb84f13099..65ed9390d4 100644 --- a/demo/35-hyperlinks.ts +++ b/demo/35-hyperlinks.ts @@ -1,7 +1,7 @@ // 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, HyperlinkRef, HyperlinkType, Packer, Paragraph } from "../build"; +import { Document, HyperlinkRef, HyperlinkType, Packer, Paragraph, Media } from "../build"; const doc = new Document({ hyperlinks: { @@ -10,14 +10,24 @@ const doc = new Document({ text: "Hyperlink", type: HyperlinkType.EXTERNAL, }, + myOtherLink: { + link: "http://www.google.com", + text: "Google Link", + type: HyperlinkType.EXTERNAL, + }, }, }); +const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg")); + doc.addSection({ children: [ new Paragraph({ children: [new HyperlinkRef("myCoolLink")], }), + new Paragraph({ + children: [image1, new HyperlinkRef("myOtherLink")], + }), ], });