import json import os from pathlib import Path from dots_ocr.utils.pptx_generator import build_pptx_from_results def main(): # 경로 설정 base_dir = Path(__file__).parent input_json_path = base_dir / "test.json" output_dir = base_dir / "output" output_pptx_path = output_dir / "test_result.pptx" # 1. Output 디렉토리 생성 output_dir.mkdir(exist_ok=True) # 2. JSON 데이터 로드 if not input_json_path.exists(): print(f"Error: {input_json_path} not found.") return print(f"Reading data from {input_json_path}...") with open(input_json_path, "r", encoding="utf-8") as f: parse_results = json.load(f) # 3. PPT 생성 # 배경 이미지가 없으므로 빈 리스트 전달 (흰 배경 생성됨) # build_pptx_from_results는 background_images 리스트 길이를 체크하여 처리함 background_images = [] print("Generating PPTX...") try: page_count, box_count = build_pptx_from_results( parse_results=parse_results, background_images=background_images, output_path=output_pptx_path ) print(f"✅ Success! Generated {output_pptx_path}") print(f" Pages: {page_count}") print(f" Text Boxes: {box_count}") except Exception as e: print(f"❌ Failed to generate PPTX: {e}") import traceback traceback.print_exc() if __name__ == "__main__": main()