“Extraia o texto do PDF Python” Respostas de código

Extraia o texto de um PDF Python

# pip3 install pdfplumber
import pdfplumber

# a single page
with pdfplumber.open(r'test.pdf') as pdf:
    first_page = pdf.pages[-0]
    print(first_page.extract_text())

# for every page
# with pdfplumber.open(r'test.pdf') as pdf:
#     for pages in pdf.pages:
#         print(pages.extract_text())
the hacker man

Extraia o texto do PDF Python

# using PyMuPDF
import sys, fitz
fname = sys.argv[1]  # get document filename
doc = fitz.open(fname)  # open document
out = open(fname + ".txt", "wb")  # open text output
for page in doc:  # iterate the document pages
    text = page.get_text().encode("utf8")  # get plain text (is in UTF-8)
    out.write(text)  # write text of page
    out.write(bytes((12,)))  # write page delimiter (form feed 0x0C)
out.close()
XeN0N

Respostas semelhantes a “Extraia o texto do PDF Python”

Perguntas semelhantes a “Extraia o texto do PDF Python”

Mais respostas relacionadas para “Extraia o texto do PDF Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código