AddImage {ReporteRs} height and width commands don't work

I am filling the docx with some images using the addImage function which has parameters for the image width and height. However, no matter what I seem to be doing, these numbers don't stick, the image is pasted at its original size.

To reproduce it, you need to create a docx, bookmark it somewhere called "image_bookmark" (insert> bookmark) and save the docx to your WD as "input.docx". Also you will need a (png) image in this folder, rename it "image".

docx.file = "output.docx")
doc = docx(template= "input.docx")
doc = addImage( doc = doc , filename = "image.png",width = 6.88, height = 2, bookmark = "image_bookmark") 
writeDoc( doc, docx.file )

      

I have attached the actual image that I am working with. I want the width to be ~ 17.49cm (page width in word), it keeps coming out as ~ 20 regardless of the width parameter.

image.png

+3


source to share


1 answer


I had the same problem and had the same versions as @lukeA, which are currently the most recent.



I found a job that can do the trick if you still have this problem. I noticed that changing the ppi in the function call changed the size of the image added to the .docx file. In windows, I opened the .png image properties to find out the files pixels per inch, which was quite high because I wanted to create a high resolution image. So to resize the image, all I did was figure out how many pixels per inch would reduce the image to the required size and inject it into the ppi part of the call.

+1


source







All Articles