#!/usr/bin/env python3 import zipfile from pathlib import Path # Create a minimal DOCX file output_path = Path('/Users/egg/Projects/Tool_OCR/demo_docs/office_tests/test_document.docx') # DOCX is a ZIP file containing XML files with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as docx: # [Content_Types].xml content_types = ''' ''' docx.writestr('[Content_Types].xml', content_types) # _rels/.rels rels = ''' ''' docx.writestr('_rels/.rels', rels) # word/document.xml with Chinese and English content document = ''' Office Document OCR Test 測試文件說明 這是一個用於測試 Tool_OCR 系統 Office 文件支援功能的測試文件。 本系統現已支援以下 Office 格式: • Microsoft Word: DOC, DOCX • Microsoft PowerPoint: PPT, PPTX 處理流程 Office 文件的處理流程如下: 1. 使用 LibreOffice 將 Office 文件轉換為 PDF 2. 將 PDF 轉換為圖片(每頁一張) 3. 使用 PaddleOCR 處理每張圖片 4. 合併所有頁面的 OCR 結果 中英混合測試 This is a test for mixed Chinese and English OCR recognition. 測試中英文混合識別能力:1234567890 Technical Information System Version: Tool_OCR v1.0 Conversion Engine: LibreOffice Headless OCR Engine: PaddleOCR Token Validity: 24 hours (1440 minutes) ''' docx.writestr('word/document.xml', document) print(f"Created DOCX file: {output_path}") print(f"File size: {output_path.stat().st_size} bytes")