super-document-processor 0.1.5__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/PKG-INFO +2 -1
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/pyproject.toml +2 -1
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/PKG-INFO +2 -1
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/requires.txt +1 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/aspose_slide_renderer.py +42 -45
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/LICENSE +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/README.md +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/__init__.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_docx.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_images.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_msg.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_pdf.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_plain_text.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_pptx.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/main.py +2 -2
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/processor.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/setup.cfg +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/SOURCES.txt +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/dependency_links.txt +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/entry_points.txt +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/super_document_processor.egg-info/top_level.txt +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/chunker.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/docx_image_utils.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/docx_xml_parser.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/optimizer.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/pdf_image_utils.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/pdf_table_utils.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/pptx_components_extract.py +0 -0
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/pptx_converter.py +2 -2
- {super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/vlm.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: super-document-processor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: High-fidelity multi-format document parsing and chunking engine for RAG pipelines
|
|
5
5
|
Author: Cinderfox
|
|
6
6
|
License: MIT
|
|
@@ -27,6 +27,7 @@ Requires-Dist: python-pptx==1.0.2
|
|
|
27
27
|
Requires-Dist: extract-msg==0.56.1
|
|
28
28
|
Requires-Dist: lxml==6.1.3
|
|
29
29
|
Requires-Dist: aspose-slides==26.8.0
|
|
30
|
+
Requires-Dist: resvg-py==0.5.0
|
|
30
31
|
Requires-Dist: python-dotenv==1.2.3
|
|
31
32
|
Requires-Dist: fastapi==0.141.1
|
|
32
33
|
Requires-Dist: uvicorn==0.52.4
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "super-document-processor"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
description = "High-fidelity multi-format document parsing and chunking engine for RAG pipelines"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -44,6 +44,7 @@ dependencies = [
|
|
|
44
44
|
"extract-msg==0.56.1",
|
|
45
45
|
"lxml==6.1.3",
|
|
46
46
|
"aspose-slides==26.8.0",
|
|
47
|
+
"resvg-py==0.5.0",
|
|
47
48
|
"python-dotenv==1.2.3",
|
|
48
49
|
"fastapi==0.141.1",
|
|
49
50
|
"uvicorn==0.52.4",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: super-document-processor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: High-fidelity multi-format document parsing and chunking engine for RAG pipelines
|
|
5
5
|
Author: Cinderfox
|
|
6
6
|
License: MIT
|
|
@@ -27,6 +27,7 @@ Requires-Dist: python-pptx==1.0.2
|
|
|
27
27
|
Requires-Dist: extract-msg==0.56.1
|
|
28
28
|
Requires-Dist: lxml==6.1.3
|
|
29
29
|
Requires-Dist: aspose-slides==26.8.0
|
|
30
|
+
Requires-Dist: resvg-py==0.5.0
|
|
30
31
|
Requires-Dist: python-dotenv==1.2.3
|
|
31
32
|
Requires-Dist: fastapi==0.141.1
|
|
32
33
|
Requires-Dist: uvicorn==0.52.4
|
{super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/aspose_slide_renderer.py
RENAMED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import io
|
|
2
|
-
import os
|
|
3
2
|
import re
|
|
4
|
-
import subprocess
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
7
3
|
|
|
8
4
|
def fix_svg_dimensions(svg_text: str, scale: float = 2.0) -> str:
|
|
9
5
|
"""
|
|
@@ -48,56 +44,57 @@ def strip_aspose_watermark_from_svg(svg_text: str) -> str:
|
|
|
48
44
|
break
|
|
49
45
|
return svg_text
|
|
50
46
|
|
|
51
|
-
def
|
|
52
|
-
"""
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
def normalize_svg_font_sizes(svg_text: str) -> str:
|
|
48
|
+
"""
|
|
49
|
+
resvg does not parse 'pt' units in font-size attributes or inline CSS (e.g. font-size="18pt" or style="font-size: 18pt").
|
|
50
|
+
Converts all font-size occurrences with 'pt' to standard pixel values:
|
|
51
|
+
px = round(pt * 96 / 72, 2)
|
|
52
|
+
"""
|
|
53
|
+
def _pt_attr_to_px(match):
|
|
54
|
+
num = float(match.group(1))
|
|
55
|
+
px = round(num * 96.0 / 72.0, 2)
|
|
56
|
+
return f'font-size="{px}px"'
|
|
57
|
+
|
|
58
|
+
def _pt_style_to_px(match):
|
|
59
|
+
num = float(match.group(1))
|
|
60
|
+
px = round(num * 96.0 / 72.0, 2)
|
|
61
|
+
return f'font-size: {px}px'
|
|
62
|
+
|
|
63
|
+
# Handle font-size="18pt" and font-size='18pt'
|
|
64
|
+
svg_text = re.sub(r'font-size="([0-9.]+)pt"', _pt_attr_to_px, svg_text)
|
|
65
|
+
svg_text = re.sub(r"font-size='([0-9.]+)pt'", _pt_attr_to_px, svg_text)
|
|
66
|
+
# Handle style="... font-size: 18pt; ..."
|
|
67
|
+
svg_text = re.sub(r'font-size\s*:\s*([0-9.]+)pt', _pt_style_to_px, svg_text)
|
|
68
|
+
return svg_text
|
|
59
69
|
|
|
60
70
|
def render_svg_to_png_bytes(svg_string: str, scale: float = 2.0) -> bytes:
|
|
61
71
|
"""
|
|
62
|
-
Renders an SVG string to PNG bytes using
|
|
72
|
+
Renders an SVG string to PNG bytes using resvg_py in-memory Rust engine.
|
|
73
|
+
Ensures watermark is stripped, inch dimensions are scaled to pixels,
|
|
74
|
+
and CSS font units (pt -> px) are normalized so all text renders crisp.
|
|
63
75
|
"""
|
|
64
76
|
clean_svg = strip_aspose_watermark_from_svg(svg_string)
|
|
65
77
|
clean_svg = fix_svg_dimensions(clean_svg, scale=scale)
|
|
66
|
-
|
|
67
|
-
resvg_bin = find_resvg_bin()
|
|
68
|
-
if not resvg_bin:
|
|
69
|
-
raise RuntimeError("Standalone native resvg binary not found in PATH or /usr/local/bin/resvg.")
|
|
70
|
-
|
|
71
|
-
import tempfile
|
|
72
|
-
with tempfile.NamedTemporaryFile(suffix=".svg", delete=False) as in_svg, \
|
|
73
|
-
tempfile.NamedTemporaryFile(suffix=".png", delete=False) as out_png:
|
|
74
|
-
in_svg.write(clean_svg.encode("utf-8"))
|
|
75
|
-
in_svg.flush()
|
|
76
|
-
in_path = in_svg.name
|
|
77
|
-
out_path = out_png.name
|
|
78
|
+
clean_svg = normalize_svg_font_sizes(clean_svg)
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
cmd = [str(resvg_bin), "-z", str(scale), in_path, out_path]
|
|
82
|
-
res = subprocess.run(cmd, capture_output=True, timeout=60)
|
|
83
|
-
if res.returncode == 0 and os.path.exists(out_path):
|
|
84
|
-
with open(out_path, "rb") as f:
|
|
85
|
-
return f.read()
|
|
86
|
-
else:
|
|
87
|
-
err_msg = res.stderr.decode("utf-8", errors="ignore").strip()
|
|
88
|
-
raise RuntimeError(f"Native resvg rasterization failed: {err_msg}")
|
|
89
|
-
finally:
|
|
90
|
-
if os.path.exists(in_path):
|
|
91
|
-
os.remove(in_path)
|
|
92
|
-
if os.path.exists(out_path):
|
|
93
|
-
os.remove(out_path)
|
|
80
|
+
import resvg_py
|
|
81
|
+
return resvg_py.svg_to_bytes(svg_string=clean_svg, zoom=float(scale))
|
|
94
82
|
|
|
95
83
|
def render_slide_to_png_bytes(aspose_slide, scale: float = 2.0) -> bytes:
|
|
96
84
|
"""
|
|
97
85
|
Exports an Aspose slide to clean SVG in memory, strips the watermark, and
|
|
98
|
-
rasterizes it to high-fidelity PNG bytes.
|
|
86
|
+
rasterizes it to high-fidelity PNG bytes using resvg.
|
|
87
|
+
Falls back to Aspose native slide image rendering only if resvg is completely unavailable.
|
|
99
88
|
"""
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
try:
|
|
90
|
+
svg_stream = io.BytesIO()
|
|
91
|
+
aspose_slide.write_as_svg(svg_stream)
|
|
92
|
+
raw_svg = svg_stream.getvalue().decode("utf-8", errors="ignore")
|
|
93
|
+
return render_svg_to_png_bytes(raw_svg, scale=scale)
|
|
94
|
+
except Exception:
|
|
95
|
+
# Fallback to Aspose native rasterizer
|
|
96
|
+
import aspose.slides as _slides
|
|
97
|
+
img = aspose_slide.get_image(float(scale), float(scale))
|
|
98
|
+
buf = io.BytesIO()
|
|
99
|
+
img.save(buf, _slides.ImageFormat.PNG)
|
|
100
|
+
return buf.getvalue()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_msg.py
RENAMED
|
File without changes
|
{super_document_processor-0.1.5 → super_document_processor-0.1.6}/document_processors/process_pdf.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -701,9 +701,9 @@ def main():
|
|
|
701
701
|
sys.exit(1)
|
|
702
702
|
|
|
703
703
|
try:
|
|
704
|
-
from super_document_processor.utils.pptx_converter import convert_pptx, create_pptx_render_zip
|
|
705
|
-
except ImportError:
|
|
706
704
|
from utils.pptx_converter import convert_pptx, create_pptx_render_zip
|
|
705
|
+
except ImportError:
|
|
706
|
+
from super_document_processor.utils.pptx_converter import convert_pptx, create_pptx_render_zip
|
|
707
707
|
|
|
708
708
|
try:
|
|
709
709
|
norm_fmt = "png" if args.format.lower() in ("png", "img", "image") else "svg"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{super_document_processor-0.1.5 → super_document_processor-0.1.6}/utils/pptx_components_extract.py
RENAMED
|
File without changes
|
|
@@ -9,14 +9,14 @@ from typing import Optional, Union, Dict, Any, List
|
|
|
9
9
|
from concurrent.futures import ThreadPoolExecutor
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
|
-
from
|
|
12
|
+
from utils.aspose_slide_renderer import (
|
|
13
13
|
strip_aspose_watermark_from_svg,
|
|
14
14
|
fix_svg_dimensions,
|
|
15
15
|
render_svg_to_png_bytes,
|
|
16
16
|
render_slide_to_png_bytes
|
|
17
17
|
)
|
|
18
18
|
except ImportError:
|
|
19
|
-
from utils.aspose_slide_renderer import (
|
|
19
|
+
from super_document_processor.utils.aspose_slide_renderer import (
|
|
20
20
|
strip_aspose_watermark_from_svg,
|
|
21
21
|
fix_svg_dimensions,
|
|
22
22
|
render_svg_to_png_bytes,
|
|
File without changes
|