Implement ImageProcessingMode which dictates how images should be handled during conversion #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Hello
The idea of this PR is to provide a working example of being able to dictate how HtmlToOpenXml should handle images that are.
This is done by overriding
ImageProcessingin the HtmlConverter constructor thus:I've also provided handling for data uris but my primary focus here has been to swap external images out so that they use
Blip.Linkinstead ofBlip.Embed. As stated above, the default behaviour remains the same (e.g. ImageProcessing.Embed) unless explicitly overridden.Example implementation - taken from a modified form of examples\Demo\Program.cs
During my tests, I have found that a Word document with 30 embedded external images has been reduced from 4MB to 10KB, so there is a sizeable reduction.
Further changes could be made later, for example providing additional rules for dictating which domains should/shouldn't be embedded, or perhaps providing a mechanism for HTML-level customisation of image processing (for example by use of an attribute such as
<img src="..." data-imageProcessing="Embed" />I also added 5 new unit tests (in ImgTests.cs) to support my changes and made some highlighted spelling corrections to some usages of
asynchronousandintended. My apologies if some changes to formatting occurred. I use ReSharper and my Visual Studio formats the documents such as braces, imports, access modifiers, etc, and I've done my best to discard those changes in my PR.Kind regards
Dan Atkinson - Atcore Technology Ltd