Unstructured-IO / Unstructured-IO/unstructured

bug/partition_pdf with analysis True and pdf_image_dpi != 200

Open
#3,985 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
HTML
Stars
15.5k
Forks
1.3k
Avg merge
4d 2h
Merged PRs (30d)
13

Description

Describe the bug
When using partition_pdf on a filepath with analysis=True and a value for pdf_image_dpi, the analysis drawings are at wrong scale.

To Reproduce

file_path = "path_to_my_pdf.pdf"
partition_pdf(filename=file_path, analysis=True, pdf_image_dpi=72, strategy="hi_res")

Expected behavior
Having the drawing at correct scale

Additional context
My understanding is that the problems occures because the function save_analysis_artifiacts called here uses an AnalysisDrawer that calls convert_pdf_to_image without using the pdf_image_dpi given to the partition_pdf function so it uses a 200 dpi value.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in unstructured/partition/pdf.py at save_analysis_artifiacts and the linked partition_pdf call, then inspect AnalysisDrawer and its convert_pdf_to_image usage. Reproduce the issue with analysis=True, strategy="hi_res", and a non-200 pdf_image_dpi; done means the analysis drawings use the requested DPI and appear at the correct scale.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.