Add export with referenced images to export_figures example

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
Christoph Auer 2024-11-27 10:13:18 +01:00
parent 35c73938a7
commit 9777f41137

View File

@ -71,10 +71,16 @@ def main():
element.get_image(conv_res.document).save(fp, "PNG")
# Save markdown with embedded pictures
content_md = conv_res.document.export_to_markdown(image_mode=ImageRefMode.EMBEDDED)
md_filename = output_dir / f"{doc_filename}-with-images.md"
with md_filename.open("w") as fp:
fp.write(content_md)
conv_res.document.save_as_markdown(md_filename, image_mode=ImageRefMode.EMBEDDED)
# Save markdown with externally referenced pictures
md_filename = output_dir / f"{doc_filename}-with-image-refs.md"
conv_res.document.save_as_markdown(md_filename, image_mode=ImageRefMode.REFERENCED)
# Save HTML with externally referenced pictures
html_filename = output_dir / f"{doc_filename}-with-image-refs.html"
conv_res.document.save_as_html(html_filename, image_mode=ImageRefMode.REFERENCED)
end_time = time.time() - start_time