Skip to content

Specifying image size during conversion to markdown #2007

@DylanDsouza00

Description

@DylanDsouza00

Question

...I have a PDF file containing numerous images, and I am trying to convert it into a PDF document. I do not want an tag to be generated for every image in the PDF. Is it possible to set restrictions on the image size, including length and width?

Below code is used to convert to a normal markdown file

source = "input/A_"  # Local Path
converter = DocumentConverter()
result = converter.convert(source)

# Create output folder if it doesn't exist
output_folder = "output"
os.makedirs(output_folder, exist_ok=True)

source_filename = os.path.basename(source)
output_filename = os.path.splitext(source_filename)[0] + ".md"  # Change extension to .md
output_path = os.path.join(output_folder, output_filename)

# Write markdown to file
with open(output_path, "w", encoding="utf-8") as file:
    file.write(result.document.export_to_markdown())

print(f"Markdown written to {output_path}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions