Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting image sizes #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vacoo
Copy link

@vacoo vacoo commented Aug 8, 2023

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)
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant