Add SVG image suport (#2487)

* Add SVG blip extentions

* SVG Image feature now works

* Add and simplify tests

* Fix falsey issue with file

Write tests
100% Coverage
This commit is contained in:
Dolan
2023-12-31 18:54:35 +00:00
committed by GitHub
parent 7570fc2bf5
commit 24c159de37
27 changed files with 615 additions and 118 deletions

View File

@ -6,6 +6,7 @@ To create a `floating` image on top of text:
```ts
const image = new ImageRun({
type: 'gif',
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
@ -26,6 +27,7 @@ By default with no arguments, its an `inline` image:
```ts
const image = new ImageRun({
type: 'gif',
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
@ -59,6 +61,7 @@ const doc = new Document({
new Paragraph({
children: [
new ImageRun({
type: [IMAGE_TYPE],
data: [IMAGE_BUFFER],
transformation: {
width: [IMAGE_SIZE],
@ -97,6 +100,7 @@ To change the position the image to be on top of the text, simply add the `float
```ts
const image = new ImageRun({
type: 'png',
data: buffer,
transformation: {
width: 903,
@ -115,6 +119,7 @@ const image = new ImageRun({
```ts
const image = new ImageRun({
type: 'png',
data: buffer,
transformation: {
width: 903,
@ -180,6 +185,7 @@ For example:
```ts
const image = new ImageRun({
type: 'gif',
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
@ -228,6 +234,7 @@ For example:
```ts
const image = new ImageRun({
type: 'gif',
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
@ -258,6 +265,7 @@ Specifies common non-visual DrawingML properties. A name, title and description
```ts
const image = new ImageRun({
type: 'gif',
data: fs.readFileSync("./demo/images/pizza.gif"),
altText: {
title: "This is an ultimate title",

View File

@ -76,7 +76,7 @@ patchDocument(fs.readFileSync("My Document.docx"), {
],
link: "https://www.google.co.uk",
}),
new ImageRun({ data: fs.readFileSync("./demo/images/dog.png"), transformation: { width: 100, height: 100 } }),
new ImageRun({ type: 'png', data: fs.readFileSync("./demo/images/dog.png"), transformation: { width: 100, height: 100 } }),
],
}),
],