Hard Code Markdown Images
this is my first post to stack overflow so please be kind :)
a little piece of python i used to do this one for me... copy and paste the entire output file directly into the markdown document... worked for me...
function to create embedded image string as base64:
def image_to_base64(image_file, output_file):
# need base 64
import base64,sys
# open the image
image = open(image_file, 'rb')
# read it
image_read = image.read()
# encode it as base 64
# after python>=3.9, use `encodebytes` instead of `encodestring`
image_64_encode = base64.encodestring(image_read) if sys.version_info <(3,9) else base64.encodebytes(image_read)
# convert the image base 64 to a string
image_string = str(image_64_encode)
# replace the newline characters
image_string = image_string.replace("\\n", "")
# replace the initial binary
image_string = image_string.replace("b'", "")
# replace the final question mark
image_string = image_string.replace("'", "")
# add the image tags
image_string = '<p><img src="data:image/png;base64,' + image_string + '"></p>'
# write it out
image_result = open(output_file, 'w')
image_result.write(image_string)
You should write the document in markdown and then convert it to PDF using a tool like pandoc
However your base64 solution would work. See this
