PDF to HTML: 4 Free Ways to Convert a PDF (2026)
November 11, 2026 · 11 min read
PDF to HTML: 4 Ways to Convert a PDF into a Web Page
Converting PDF to HTML comes down to one choice: should the result look like the PDF, or behave like a web page? Pick pdf2htmlEX for a close visual copy, Poppler's pdftohtml or LibreOffice for quick local output, or a text-first route through Markdown when you want clean, editable HTML. All four are free.
How Do You Turn a PDF File into HTML?
The right tool depends on what you need back, because a PDF carries drawing instructions rather than document structure. Some converters copy those instructions into CSS so the page looks the same. Others try to infer headings, lists and tables from them, and the four free methods below split along that line.
| Method | Output style | Best for | Install |
|---|---|---|---|
| pdf2htmlEX | Layout-faithful, fonts embedded | Archives and print-like previews | Linux package or Docker image |
| Poppler pdftohtml | Flowing text, or positioned text per page | Quick local extraction and scripts | poppler (Homebrew) or poppler-utils (apt) |
| LibreOffice headless | One paragraph per PDF line | Machines that already run LibreOffice | LibreOffice |
| PDF to Markdown, then HTML | Semantic headings, lists and tables | Content headed for a website | Nothing, two web tools |
If you're unsure, ask whether anyone will edit the HTML later. If they will, go text-first. If the page must match the printed original, use pdf2htmlEX. If you still have the original Word file, converting Word to HTML keeps the headings and lists a PDF throws away. If the PDF came from LaTeX and you have the .tex file, convert the LaTeX to HTML instead.
Layout-Faithful vs Semantic HTML: What a Converter Hands You
Layout-faithful output pins every line in place with absolute positioning, so the browser draws it exactly where the PDF did. Here's a trimmed excerpt from pdftohtml -c (Poppler 25.10.0) run on a one-page report:
<div id="page1-div" style="position:relative;width:892px;height:1262px;">
<img width="892" height="1262" src="out001.png" alt="background image"/>
<p style="position:absolute;top:61px;left:85px;white-space:nowrap" class="ft00"><b>Quarterly Report</b></p>
<p style="position:absolute;top:180px;left:85px;white-space:nowrap" class="ft03"><b>Highlights</b></p>
<p style="position:absolute;top:332px;left:87px;white-space:nowrap" class="ft01">Q1</p>
<p style="position:absolute;top:332px;left:159px;white-space:nowrap" class="ft01">120k</p>
</div>
The title is a bold paragraph, not a heading. The table is a set of loose paragraphs that only line up because of their top and left values. On a 375-pixel phone, the 892-pixel page can't reflow, and a screen reader hears a flat run of text.
Semantic output says what each piece of content is instead:
<h1>Quarterly Report</h1>
<h2>Highlights</h2>
<table>
<thead><tr><th>Quarter</th><th>Revenue</th></tr></thead>
<tbody><tr><td>Q1</td><td>120k</td></tr></tbody>
</table>
This version reflows on any screen and takes your site's styles, but it loses the original fonts, spacing and page breaks. We prefer semantic HTML for anything that will live on a website. Layout-faithful output earns its place in archives and print-style previews, where matching the original matters more than editing it.
Method 1: pdf2htmlEX for HTML That Looks Like the PDF
pdf2htmlEX places real, selectable HTML text at the same positions and in the same fonts as the original, over a background layer for graphics. By default it packs fonts, CSS and images into a single HTML file. It's free software under GPLv3+.
The project's Quick Start opens with a run like this one, which writes report.html to the current folder:
pdf2htmlEX --zoom 1.3 report.pdf
Two variations adapted from the same Quick Start recipes:
# Pages 3 to 5 only, fitted to a 1024-pixel width
pdf2htmlEX -f 3 -l 5 --fit-width 1024 report.pdf
# Write to out/ with fonts, images, CSS, JavaScript and outline as separate files
pdf2htmlEX --embed cfijo --dest-dir out report.pdf
Installing it takes more effort than the other methods. The GitHub releases page offers .deb packages and AppImages, plus a list of Docker images, all built for x86_64 Linux. The newest tagged release, as of November 2026, is still a 0.18.8 release candidate from 2020, so on macOS or Windows the Docker image is the practical route.
The output is the closest free match to the original, but it's hard to edit by hand. Every line is a positioned element with generated class names, so plan to treat it as a finished snapshot.
Method 2: Poppler pdftohtml and the Flags That Shape Its Output
Poppler's pdftohtml comes with the poppler formula on Homebrew and the poppler-utils package on Debian and Ubuntu:
brew install poppler
sudo apt install poppler-utils
Run it with no flags, as in pdftohtml report.pdf out, and you get a frameset: out.html, a navigation file called out_ind.html, and the content in outs.html. The flags below change that. All of them are listed in the pdftohtml man page, and all of them appear in version 25.10.0's help output. We ran the main ones on a sample report.
| Flag | Effect on the HTML |
|---|---|
-noframes | One out.html with flowing text and a line break after every PDF line |
-c | Complex mode: one file per page, text absolutely positioned over a PNG background |
-s | All pages in one document; in our tests it also switched to positioned output |
-i | Skips images, including the page background PNGs |
-f 2 -l 5 | Converts pages 2 to 5 only |
-p | Rewrites links to .pdf files so they point to .html files |
-stdout | Prints the HTML to the terminal instead of a file |
-zoom 1.5 | Scales the page (1.5 is the default) |
For a quick copy of the text, the flowing mode is the one you want:
pdftohtml -noframes -i report.pdf out
Here's the start of the real <body> it produced for the same report:
<b>Quarterly Report</b><br/>
Revenue grew in every quarter this year, led by the new subscription plan. See <a href="https://example.com/">the site</a>.<br/>
<b>Highlights</b><br/>
• Churn fell to 2 percent<br/>• Two new regions launched<br/>
<b>Quarter Revenue</b><br/>
Q1<br/>
120k<br/>
The heading became bold text and the table collapsed into one value per line. Links did survive as real anchor tags, and if the PDF has bookmarks, pdftohtml appends them as a Document Outline list. If you're after Markdown rather than HTML, our PDF to Markdown guide shows how to pipe this output through Pandoc. In a Python script, calling pdftohtml through subprocess is often simpler than parsing the PDF yourself.
Method 3: Convert PDF to HTML with LibreOffice from the Command Line
LibreOffice opens a PDF in Draw, and its command-line converter can save that as HTML. The --headless and --convert-to switches are documented on LibreOffice's start parameters page:
soffice --headless --convert-to html report.pdf
On macOS, if soffice isn't on your PATH, it lives inside the app at /Applications/LibreOffice.app/Contents/MacOS/soffice.
In our test with LibreOffice 26.8, the command reported the file as a Draw document and used the draw_html_Export filter. The result was one HTML file in which every line of the PDF became its own paragraph. Bold survived, but headings and the link didn't, and each page started with an empty <h1>, which carried a page break style on every page after the first. Bullets also landed in separate paragraphs from their text.
That makes it the weakest of the four for structure. It's worth using only when LibreOffice is already installed and you need the text in an HTML wrapper fast. Don't expect Pandoc to fill the gap either: the Pandoc manual lists PDF as an output format only, so it can't read a PDF at all. If you can copy the text out of the PDF instead, a text to HTML converter wraps it in paragraph tags.
Method 4: The Text-First Route Through Markdown
This route gives you the cleanest semantic HTML, and it costs you the visual layout. It takes three steps:
- Upload the PDF at PDF to Markdown. It runs on our server and reads the text layer, guessing headings from font size and tables from the gaps between text. Each conversion uses one of the three free server-side operations a day, with no account needed. Pro removes the daily cap.
- Fix what the guesser missed: heading levels, list markers and table rows.
- Paste the Markdown into Markdown to HTML and click Convert to HTML. It runs in your browser, returns a full HTML document and doesn't count toward the daily pool.
The editor's Export as HTML works too, but it runs on the server and spends a pool operation, so the tool page is the better last step. Here's what a cleaned-up extract of the sample report looks like. Edit it, and the preview shows the headings, list and table as real HTML elements:
The limitation is real: this route drops the original fonts, page layout and images. Our PDF to Markdown tool doesn't extract embedded images or read link annotations, so you re-add images by URL and re-create links by hand. For other ways to render the Markdown, such as Pandoc or a JavaScript library, see how to convert Markdown to HTML.
Why Scanned PDFs and Complex Layouts Break PDF to HTML Conversion
A scanned PDF is a stack of page images with no text layer. pdf2htmlEX will still display the images, but every text-based method, our PDF to Markdown tool included, returns little or nothing. Add a text layer with OCR first, as the PDF to Markdown guide linked above explains. A quick test: if you can't select words in your PDF viewer, there's no text layer.
Text-based PDFs cause their own HTML problems:
- A two-column page can look right in positioned output while its source order mixes the columns. Screen readers and copy-paste follow that source order.
- Running headers, footers and page numbers become stray paragraphs that repeat once per page.
- A word hyphenated at a line end stays split, with a line break between its halves in flowing output.
- Ligatures such as fi can turn into odd characters when the PDF's font lacks a proper Unicode mapping.
- Tables arrive as loose cells, as the pdftohtml excerpt above shows.
Whichever method you pick, budget time for cleanup. Delete the repeated headers and footers, rejoin split words, rebuild tables as real <table> markup, set heading levels, and add alt text to every image you put back. The same cleaned-up file is what you need if you later convert the HTML to EPUB for e-readers.
Quick Answers on Turning PDFs into Web Pages
No single PDF to HTML converter wins every case. Use pdf2htmlEX when the page must look like the original, pdftohtml for fast local extraction, and the text-first route when the HTML is headed for a website. If you go text-first, start at PDF to Markdown and tidy the result in the editor. You'll end up with clean headings, lists and tables, ready for the Markdown to HTML tool.