You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
466 B
19 lines
466 B
# -*- coding: utf-8 -*-
|
|
"""Extract plain text from a PDF (pypdf). Usage: python scripts/extract-pdf-text.py <pdf>"""
|
|
import sys
|
|
from pypdf import PdfReader
|
|
|
|
def main():
|
|
path = sys.argv[1]
|
|
reader = PdfReader(path)
|
|
parts = []
|
|
for page in reader.pages:
|
|
t = page.extract_text() or ""
|
|
if t.strip():
|
|
parts.append(t)
|
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
print("\n".join(parts))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|