docx
docx copied to clipboard
Getting image sizes
I needed to replace the signature image on the document. And relying on the image index turned out to be extremely unreliable. They can switch places. So I did getting a map of images with their dimensions. And then you can find the desired image by its size and make a replacement
imagesSizes := docx1.ImagesSizes()
for key := range imagesSizes {
if imagesSizes[key].Width == 80 && imagesSizes[key].Height == 30 {
docx1.ReplaceImage(key, signature)
} else if imagesSizes[key].Width == 130 && imagesSizes[key].Height == 30 {
docx1.ReplaceImage(key, usernameSignature)
}
}