Open maifeeulasad opened 2 years ago
Had a similar issue, my solution was to make the following local changes to h2d.py - inspired by this StackOverflow answer
No exhaustive testing but appears to be working for my purposes.
import base64
import io
handle_img
This is added just before the # add image to doc
comment
# check if image starts with data:.*base64,
if image and image.startswith('data:image/'):
#-- convert to bytes ready to insert to docx
image = image.split(',')[1]
image = base64.b64decode(image)
image = io.BytesIO(image)
Had a similar issue, my solution was to make the following local changes to h2d.py - inspired by this StackOverflow answer
No exhaustive testing but appears to be working for my purposes.
Add some extra imports at the top
import base64 import io
Add a base64 check and conversion to
handle_img
This is added just before the
# add image to doc
comment# check if image starts with data:.*base64, if image and image.startswith('data:image/'): #-- convert to bytes ready to insert to docx image = image.split(',')[1] image = base64.b64decode(image) image = io.BytesIO(image)
It works!
I had a similar issue, rather than embedding the image this line is in the word document:
<image: fZvATdwBXdw45YLCfdwET=>
I'm trying to create a document with image, and that image has a base64 value as it's source. But when I try add this, it gives me, error saying it has a long name:
The HTML given to it, is pretty simple:
Just an image inside a paragraph.