pdf.to_html
pdf.to_html(src[, pages], [page=], [images=false])
Input: src[, pages], page, images · Output: no output
What it is
A simple HTML fragment for the pages asked for (default all; pages is positional, not a keyword): one <section class="page" data-page="N"> per page holding one <p> per paragraph, text escaped (& < >). A new paragraph starts where the gap between two lines exceeds 1.6 times the font size; a paragraph's lines are joined with spaces and line-end hyphenation is repaired (as normalize=true). Layout and fonts are not reproduced: no sizes, colours, columns, tables, links or positions, and no headings are recognised -- it is the recovered text in page order (the same limits as pdf.extract_text(lines=true) apply, including the error for a page whose lines cannot be recovered). With images=true each page's images follow its text as <img> data URIs (JPEG kept as stored, other images re-encoded as PNG; an image that cannot be decoded becomes an HTML comment naming why); their position on the page is not recovered, and the HTML can get large.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
pdf.to_html(src[, pages], [page=], [images=false]) | src[, pages] —not documented yetpage optionalpages is positional, not a keyword): one <section class="page" data-page="N"> per page holding one <p> per paragraph, text escaped (& < >).images optional (default false)With images=true each page's images follow its text as <img> data URIs (JPEG kept as stored, other images re-encoded as PNG. | not documented yet | A new paragraph starts where the gap between two lines exceeds 1.6 times the font size; a paragraph's lines are joined with spaces and line-end hyphenation is repaired (as normalize=true). |
Examples
No documentation example calls this form yet. The File I/O chapter is where one belongs.
How it works
pdf.to_html(src, [pages], [images=false]) -> Str.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.