super-document-processor 0.1.4__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.
Files changed (30) hide show
  1. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/PKG-INFO +9 -2
  2. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/README.md +6 -0
  3. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/pyproject.toml +3 -2
  4. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/PKG-INFO +9 -2
  5. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/requires.txt +2 -1
  6. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/aspose_slide_renderer.py +42 -45
  7. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/LICENSE +0 -0
  8. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/__init__.py +0 -0
  9. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_docx.py +0 -0
  10. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_images.py +0 -0
  11. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_msg.py +0 -0
  12. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_pdf.py +0 -0
  13. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_plain_text.py +0 -0
  14. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/document_processors/process_pptx.py +0 -0
  15. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/main.py +2 -2
  16. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/processor.py +0 -0
  17. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/setup.cfg +0 -0
  18. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/SOURCES.txt +0 -0
  19. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/dependency_links.txt +0 -0
  20. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/entry_points.txt +0 -0
  21. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/super_document_processor.egg-info/top_level.txt +0 -0
  22. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/chunker.py +0 -0
  23. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/docx_image_utils.py +0 -0
  24. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/docx_xml_parser.py +0 -0
  25. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/optimizer.py +0 -0
  26. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/pdf_image_utils.py +0 -0
  27. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/pdf_table_utils.py +0 -0
  28. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/pptx_components_extract.py +0 -0
  29. {super_document_processor-0.1.4 → super_document_processor-0.1.6}/utils/pptx_converter.py +2 -2
  30. {super_document_processor-0.1.4 → 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.4
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
@@ -26,7 +26,8 @@ Requires-Dist: python-docx==1.2.0
26
26
  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
- Requires-Dist: aspose-slides==26.7.0
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
@@ -255,6 +256,12 @@ curl -X POST "http://localhost:8000/convert/pptx?format=png&as_zip=true" \
255
256
 
256
257
  #### Convert Mounted Volume Path via JSON Body
257
258
  ```bash
259
+ # Convert specific slide to PNG
260
+ curl -X POST "http://localhost:8000/convert/pptx" \
261
+ -H "Content-Type: application/json" \
262
+ -d '{"file_path": "/data/presentation.pptx", "slide": 1, "format": "png"}' -o slide_1.png
263
+
264
+ # Convert all slides to SVG
258
265
  curl -X POST "http://localhost:8000/convert/pptx" \
259
266
  -H "Content-Type: application/json" \
260
267
  -d '{"file_path": "/data/presentation.pptx", "format": "svg"}'
@@ -217,6 +217,12 @@ curl -X POST "http://localhost:8000/convert/pptx?format=png&as_zip=true" \
217
217
 
218
218
  #### Convert Mounted Volume Path via JSON Body
219
219
  ```bash
220
+ # Convert specific slide to PNG
221
+ curl -X POST "http://localhost:8000/convert/pptx" \
222
+ -H "Content-Type: application/json" \
223
+ -d '{"file_path": "/data/presentation.pptx", "slide": 1, "format": "png"}' -o slide_1.png
224
+
225
+ # Convert all slides to SVG
220
226
  curl -X POST "http://localhost:8000/convert/pptx" \
221
227
  -H "Content-Type: application/json" \
222
228
  -d '{"file_path": "/data/presentation.pptx", "format": "svg"}'
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "super-document-processor"
7
- version = "0.1.4"
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"
@@ -43,7 +43,8 @@ dependencies = [
43
43
  "python-pptx==1.0.2",
44
44
  "extract-msg==0.56.1",
45
45
  "lxml==6.1.3",
46
- "aspose-slides==26.7.0",
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.4
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
@@ -26,7 +26,8 @@ Requires-Dist: python-docx==1.2.0
26
26
  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
- Requires-Dist: aspose-slides==26.7.0
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
@@ -255,6 +256,12 @@ curl -X POST "http://localhost:8000/convert/pptx?format=png&as_zip=true" \
255
256
 
256
257
  #### Convert Mounted Volume Path via JSON Body
257
258
  ```bash
259
+ # Convert specific slide to PNG
260
+ curl -X POST "http://localhost:8000/convert/pptx" \
261
+ -H "Content-Type: application/json" \
262
+ -d '{"file_path": "/data/presentation.pptx", "slide": 1, "format": "png"}' -o slide_1.png
263
+
264
+ # Convert all slides to SVG
258
265
  curl -X POST "http://localhost:8000/convert/pptx" \
259
266
  -H "Content-Type: application/json" \
260
267
  -d '{"file_path": "/data/presentation.pptx", "format": "svg"}'
@@ -3,7 +3,8 @@ python-docx==1.2.0
3
3
  python-pptx==1.0.2
4
4
  extract-msg==0.56.1
5
5
  lxml==6.1.3
6
- aspose-slides==26.7.0
6
+ aspose-slides==26.8.0
7
+ resvg-py==0.5.0
7
8
  python-dotenv==1.2.3
8
9
  fastapi==0.141.1
9
10
  uvicorn==0.52.4
@@ -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 find_resvg_bin() -> Optional[Path]:
52
- """Locates the standalone native resvg binary if installed."""
53
- import shutil
54
- for candidate in ["/usr/local/bin/resvg", "/usr/bin/resvg", "resvg", "resvg.exe"]:
55
- found = shutil.which(candidate)
56
- if found and os.access(found, os.X_OK):
57
- return Path(found)
58
- return None
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 the standalone native resvg CLI.
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
- try:
80
- print(f"⚡ [Rasterizer] Using standalone native resvg CLI at scale={scale}", flush=True)
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
- svg_stream = io.BytesIO()
101
- aspose_slide.write_as_svg(svg_stream)
102
- raw_svg = svg_stream.getvalue().decode("utf-8", errors="ignore")
103
- return render_svg_to_png_bytes(raw_svg, scale=scale)
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()
@@ -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"
@@ -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 super_document_processor.utils.aspose_slide_renderer import (
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,