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

Manual image provisioning stopped working #26

Closed gyeadon closed 6 years ago

gyeadon commented 6 years ago

Hi, just thought I'd report my finding... I've just tried v2.0 coming from v1.5. Everything works the same for my purposes except for manual image provisioning. In v1.5 I can set the image data in my ProvisionImage event handler as follows: e.Data = File.ReadAllBytes(filepath); In v2.0 the syntax has changed, so it now looks like this: e.Provision(File.ReadAllBytes(filepath)); The old version works but the new version does not with the same HTML source and image URL and data. If I disable the manual provisioning then the automatic HTTP retrieval works fine in either version. This isn't a big problem for me - I could just use the automatic HTTP download or stick with v1.5.

gyeadon commented 6 years ago

I just grabbed the code and stepped through it out of curiosity... Basically, a local instance of HtmlImageInfo is passed to the ProvisionImage event handler. The handler sets the RawData through the Provision method. But then the method ImageProvisioningProvider.Provision checks a different instance of HtmlImageInfo, where the RawData will always be null in this case.

onizet commented 6 years ago

Hello Gyeadon,

Thank you for your troubleshooting. I have just pushed a new nuget version. There is such a gap between 1.5 and 2.0.0 that it don't worth to stick with that old one :)

gyeadon commented 6 years ago

That's working perfectly now. Thank you!