-
-
Notifications
You must be signed in to change notification settings - Fork 568
Open
Description
I just spent about 3 hours pulling my hair out trying to figure out why SVG wasn't rendering properly.
And I am not sure if this is a problem with my environment or this specific SVG file.
I am writing this for anyone who may come across a similar issue in the future
function getSVGImageFromBuffer(imageBuffer, width = 100, height = 100) {
return new ImageRun({
type: 'svg',
data: Buffer.from( imageBuffer.svg ),
transformation: { width: width, height: height },
fallback: {
type: "png",
data: imageBuffer.png,
transformation: {
width: width,
height: height
}
},
});
}When trying to use it the way above, I get the following result

But when commenting out the type: 'svg' line as follows:
function getSVGImageFromBuffer(imageBuffer, width = 100, height = 100) {
return new ImageRun({
// type: 'svg',
data: Buffer.from( imageBuffer.svg ),
transformation: { width: width, height: height },
fallback: {
type: "png",
data: imageBuffer.png,
transformation: {
width: width,
height: height
}
},
});
}I get a nice crisp SVG in the output docx file. works!
Here is the original SVG file, in case you need it for debugging
"docx": "^9.1.1", npm package version
node v20.16.0
I assume this is not the intended behaviour. I would love to help fix this
If there is any more info needed, I would love to provide it.
Metadata
Metadata
Assignees
Labels
No labels