Skip to content

Convert PDFs in Python

Python functions that turn PDFs into Word, PowerPoint, EPUB, Excel or CSV, and images, Markdown or Office files into PDFs.

Each writes a new file and returns its path and size, plus what it found (pages, tables, slides or chapters).

FunctionWhat it doesReturns
to_docx(path, output, pages=)Editable Word: headings, bold and italic, lists, tables; OCR for scansWordResult
to_pptx(path, output, pages=)PowerPoint, one slide per page, text as text boxesSlidesResult
to_epub(path, output, title=, author=, language="en", split="headings"|"pages")EPUB 3 e-book in chaptersEpubResult
extract_tables(path, output, pages=, format="xlsx"|"csv"|"json"|"markdown")Tables and vector charts; output ends in the format’s extensionTablesResult
from_images(inputs, output)JPG or PNG images to PDF, one page eachWritten
from_markdown(path, output, page_size="A4"|"Letter", title=)Typeset a Markdown file as a PDFWritten
from_office(path, output)Word, Excel, PowerPoint or OpenDocument to PDF (needs LibreOffice)OfficeResult

Examples

Python
import superpdf

word = superpdf.to_docx("report.pdf", "report.docx")
print(word["tables"], "tables")

superpdf.extract_tables("report.pdf", "tables.xlsx")  # one sheet per table
superpdf.extract_tables("report.pdf", "tables.csv", format="csv")
superpdf.to_pptx("slides.pdf", "slides.pptx")
superpdf.to_epub("book.pdf", "book.epub", author="Ada Lovelace")

superpdf.from_images(["page1.jpg", "page2.png"], "scan.pdf")
superpdf.from_markdown("notes.md", "notes.pdf", page_size="Letter")
superpdf.from_office("budget.xlsx", "budget.pdf")                  # needs LibreOffice

All functions are listed on All functions.