Question

I have an application that generates an image and then pushes this to the browser. The image displays with absolutely no difficulty, and can also be saved by right clicking, and can be pasted without issue into applications such as Gimp but cannot be pasted into MS Word. I fiddled with all aspects of the application to make sure that content-types and all other headers are correct, but this has no effect on being able to paste in the image.

Was it helpful?

Solution

The solution is a little strange. It is related to the apparent fact that MS Word actually re-downloads the image from the web based on the contents of the "HTML Format" format stored in the clipboard. Because of this, issues with the URL can cause the image to not paste correctly.

In my case, the URL was too long. I was passing a lot of parameters to my application and the URL string exceeded 255 characters. It looks like the magic number is 253. So, if you can't seem to copy dynamically generated images into MS Word, this could be your issue.

Also, since MS Word is doing a request against the URL for the image, it will also fail (although in a stranger way) if your application uses a self-signed SSL certificate, because MS Word will fail when trying to connect securely.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top