[MSWordUtils] Insert image before bookmark oversized
Forge component by Stuart Harris
Application Type
Reactive

Hello, I'm working on a project in which multiple files are opened from service studio, edited and zipped. But I keep running into an issue where the Binary Data format of the PNG's I import (all are 480x120 in size) get a border added to them to where they turn into a 750x188 PNG, the rest is all transparent, but it does mess with the page lay-out.
I was wondering if there was a way to either keep them as their original size.
I've used both the ReplaceBookmarkwithImage & InsertImageBeforeBookmark functions and tried this with both the Binary Data of the images as JPG's and PNG's.
The PNG format is the most consistent and least intrusive as the added pixels are all transparent and most of the time run off-page, where the lay-out actively tries to fit in the JPG's and on top of this the JPG's sometimes also have a slightly larger or wider size, where PNG always outputs as 750x188 when you give it a 480x120 PNG.
To quickly generate a few PNG's I use the SignaturePad component and set it's height & width to those fixed values.
Essentially the functions just stretch the images by around 50-55% while retaining the aspect ratio and I would like them to not stretch at all, retaining their current dimensions.

Kind regards,
Steve


Input : 


Output : 

I have fixed the issue by reversing the calculation and using the InsertImageBeforeBookmark function. Then inputting the smaller size (380x75) into the MSWordImage structure. In the document they are then stretched back to a 480x120 pixel image.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.