How can I convert a PDF to HTML for UI rendering in Python?

May 3, 2025 3 answers
Asked by BAZAAR STALL
Hi everyone! I'm looking for a way to convert a PDF into HTML in Python, preferably with options that are either open-source or paid. The PDF I have includes specific elements like bold, italic text, font sizes, new lines, tab spaces, etc. I want to maintain all these formatting options so I can render the PDF content directly in the UI. Additionally, I'd like to know if there's a way to create a new PDF based on any updates made in the UI. Any suggestions?

Answers

all ears
You should try pdf2htmlex! It does a great job converting PDFs to HTML while retaining all the original styles. Plus, you can use PyMuPDF for text extraction and formatting adjustments.
Reply to this answer
well_worth_asking
Honestly, PDF format is kind of a pain to work with; I'd recommend exploring other options if possible. It usually leads to more hassle than itโ€™s worth.
Reply to this answer
vintage.projection.booth
Check out pandoc; it's about as close as you can get to what you're looking for. Just a heads up, thoughโ€”it might not be 100% accurate in the conversion.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions