elements_json JSONB: структура документа в БД, PDF page, v1.12
This commit is contained in:
@@ -128,6 +128,7 @@ def _parse_pdf(file_bytes: bytes) -> dict:
|
||||
|
||||
with pdfplumber.open(io.BytesIO(file_bytes)) as pdf:
|
||||
for page in pdf.pages:
|
||||
pn = page.page_number
|
||||
# Текст страницы
|
||||
text = page.extract_text()
|
||||
if text:
|
||||
@@ -138,6 +139,7 @@ def _parse_pdf(file_bytes: bytes) -> dict:
|
||||
"type": "paragraph",
|
||||
"style": "",
|
||||
"text": line,
|
||||
"page": pn,
|
||||
})
|
||||
|
||||
# Таблицы на странице
|
||||
@@ -147,6 +149,7 @@ def _parse_pdf(file_bytes: bytes) -> dict:
|
||||
result["elements"].append({
|
||||
"type": "table",
|
||||
"rows": tbl,
|
||||
"page": pn,
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user