bugfix
This commit is contained in:
parent
91ed098680
commit
df664fd29c
@ -9,7 +9,7 @@ from bs4 import BeautifulSoup
|
|||||||
from pptx import Presentation
|
from pptx import Presentation
|
||||||
from openpyxl import load_workbook
|
from openpyxl import load_workbook
|
||||||
import mobi
|
import mobi
|
||||||
import PyPDF2
|
from pypdf import PdfReader
|
||||||
import html2text
|
import html2text
|
||||||
|
|
||||||
class MyMobiLoader:
|
class MyMobiLoader:
|
||||||
@ -48,16 +48,16 @@ class MyChmLoader:
|
|||||||
class MyPdfLoader:
|
class MyPdfLoader:
|
||||||
def __init__(self, file_path, **kw):
|
def __init__(self, file_path, **kw):
|
||||||
self.filepath = file_path
|
self.filepath = file_path
|
||||||
self.reader = None
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
"""Reads the PDF file and returns all text as a single string."""
|
"""Reads the PDF file and returns all text as a single string."""
|
||||||
text = ''
|
text = ''
|
||||||
with open(self.filepath, 'rb') as file:
|
reader = PdfReader(self.filepath)
|
||||||
self.reader = PyPDF2.PdfReader(file)
|
pts = []
|
||||||
for page in self.reader.pages:
|
for page in reader.pages:
|
||||||
text += page.extract_text() or ''
|
t = page.extract_text() or ''
|
||||||
return ' '.join(text.split('\t'))
|
pts.append(' '.join(t.split('\t')))
|
||||||
|
return ' '.join(pts)
|
||||||
|
|
||||||
class MyDocLoader:
|
class MyDocLoader:
|
||||||
def __init__(self, file_path):
|
def __init__(self, file_path):
|
||||||
|
Loading…
Reference in New Issue
Block a user