Skip to content

Commit

Permalink
docs: add export with embedded images (#175)
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm authored Oct 24, 2024
1 parent 8208c93 commit 8d356aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/examples/export_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from pathlib import Path

from docling_core.types.doc import PictureItem, TableItem
from docling_core.types.doc import ImageRefMode, PictureItem, TableItem

from docling.datamodel.base_models import FigureElement, InputFormat, Table
from docling.datamodel.pipeline_options import PdfPipelineOptions
Expand Down Expand Up @@ -71,6 +71,12 @@ def main():
with element_image_filename.open("wb") as fp:
element.image.pil_image.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)

end_time = time.time() - start_time

_log.info(f"Document converted and figures exported in {end_time:.2f} seconds.")
Expand Down

0 comments on commit 8d356aa

Please sign in to comment.