Implementing an Image_Handler and Header-Styles #1
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.
To be able to use images in docx reports and also headers from markdown, I decided to made these few simple changes.
To be able to use it also from DFIR-IRIS, I will also create a pullrequest there.
HTML-Tags in Links
Some people use HTML-Tags in link descriptions for example to add an Icon or emphasize something. This produces then a corrupt document.xml:
Maybe this is elsewhere the case too 🤔
Header Styles
We use a lot of markdown in our reports and therefore also headers, which where just stripped of till now.
I extended the styles with header1 to header5 and the DocxRenderer to use it as all other tags.
Image-Handler
Since DFIR-IRIS can handle Datastore-Images we also need them in our Reports. Therefore I have implemented an image_handler based on the PictureGlobal which can now handle local and http(s) images.
It downloads all the images and stores them in a subfolder of the generating report and adds them via the already implemented logic.
There is a inconvenience in docx.image.tiff class which also parses EXIF information from JPEG files. In case there is an unreadable or unknown resolution tag, the image cannot be added. I have not spotted this errors with PNGs. Because this costed me quite some time to figure out, i added a little better log and error message.
Open issue: python-openxml/python-docx#1124
Thanks for your work!
Lukas