onizet / html2openxml

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments into templated Word.
MIT License
321 stars 109 forks source link

image name tag contains full base64 string #88

Closed tecxx closed 3 years ago

tecxx commented 3 years ago

Hello! Thanks for this nice library.

there is one minor thing i'd like to suggest an improvement for. the <img tag converter generates an xml object "wp:docPr" with a field "name" that contains the contents of the variable "imageSource"

image

in case of http:// or file:// links this is more or less ok (altough still strange), but in case of base64-inline images, this happens:

image

-> the entire base64-encoded image ends up in the document multiple times in the "name" tags. i'm surprised this even works correctly, for large images the name tag is huge.

wouldn't it make sense to just generate a random name like "imagex" or maybe even better a random GUID? as far as i understand the "name" tag is not relevant, the image itself is a binary file in the subfolder "media" and insertion is done via two things:

i may be wrong - this is my first endeavour into this file format.