Files
docx-js/demo/35-hyperlinks.ts

20 lines
507 B
TypeScript

// 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";
const doc = new Document();
const link = doc.createHyperlink("http://www.example.com", "Hyperlink");
doc.addSection({
children: [
new Paragraph({
children: [link],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});