# doc2ppt **Repository Path**: zhou-jiming/doc2ppt ## Basic Information - **Project Name**: doc2ppt - **Description**: 根据docx文档,利用api调用人工智能,提炼成演讲稿 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-23 - **Last Updated**: 2025-10-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1. # Word Document to PPT Intelligent Generation Tool - User Manual ## Tool Overview The Word Document to PPT Intelligent Generation Tool is a Python-based automated utility that intelligently converts Word document content into PowerPoint presentations. The tool supports two modes: - **AI Intelligent Refinement Mode**: Uses DeepSeek API for smart content analysis and refinement - **Basic Extraction Mode**: Uses built-in algorithms to extract key content ## Features ### 🚀 Core Functions - **Intelligent Structure Analysis**: Automatically identifies chapter structure in Word documents - **Content Refinement**: Condenses lengthy documents into PPT-friendly key points - **Automatic Layout**: Generates professional and aesthetically pleasing PPT layouts - **AI Enhancement**: Optimizes content expression using large language models ### 📊 Output Content - Cover page - Table of contents page - Chapter title pages - Content slides - Key points summary page - Closing page ## System Requirements ### Hardware & Software - Windows/MacOS/Linux - Python 3.7 or higher - Microsoft PowerPoint (for viewing generated PPT files) ### Python Dependencies bash ``` pip install python-docx python-pptx requests ``` ## Installation ### Method 1: Direct Execution 1. Ensure Python 3.7+ is installed 2. Install required dependencies 3. Download the `apidoc2ppt.py` file 4. Run the program ### Method 2: Run from Source Code bash ``` git clone cd project-directory pip install -r requirements.txt python apidoc2ppt.py ``` ## Configuration ### API Key Configuration (Optional) To use AI intelligent refinement features, configure DeepSeek API key: **Method 1: Direct Code Modification** python ``` # Uncomment and add your API key in main() function DEEPSEEK_API_KEY = "sk-your-actual-api-key-here" ``` **Method 2: Environment Variables** python ``` import os DEEPSEEK_API_KEY = os.getenv('DEEPSEEK_API_KEY') ``` ### Obtaining API Key 1. Visit [DeepSeek Official Website](https://www.deepseek.com) 2. Register an account and obtain API key 3. Ensure sufficient account balance ## Usage Instructions ### Basic Usage Process 1. **Start the Program** bash ``` python apidoc2ppt.py ``` 1. **Input Document Path** - Program will prompt for Word document path - Drag and drop document into command line window - Or manually enter full path 2. **Wait for Processing** - Program automatically analyzes document structure - Processes content based on configured mode - Generates PPT file 3. **View Results** - Program automatically opens generated PPT file - Output file saved in same directory as original Word document ### Command Line Parameters (Optional Modifications) Adjustable default parameters in code: python ``` # Default document path (used if no input provided) docx_path = r"e:\temp\img2ppt\doc_folder\06-第1章.docx" # Output file naming convention output_ppt_path = f"{base_name}_{'AI_Refined' if converter.use_api else 'Basic'}.pptx" ``` ## Document Format Requirements ### Supported Formats - Word documents in `.docx` format - Does not support legacy `.doc` format ### Recommended Document Structure For optimal conversion results, ensure Word documents have clear structure: **Recommended Format:** text ``` Chapter 1 Chapter Title 1.1 Section Title Content text... 1.2 Section Title Content text... Chapter 2 Chapter Title 2.1 Section Title Content text... ``` **Heading Styles:** - Use Word's "Heading 1", "Heading 2" styles - Or include clear identifiers like "Chapter X", "X.X" ## Output Quality ### PPT Structure 1. **Cover Page**: Document title + generation mode identifier 2. **Table of Contents**: Automatically generated chapter index 3. **Chapter Pages**: Overview page for each chapter 4. **Content Pages**: Key points for each section 5. **Summary Page**: Consolidated key points from document 6. **Closing Page**: Thank you + Q&A ### Visual Style - Professional business style - Consistent fonts and colors - Clear hierarchical structure - Appropriate text density ## Mode Comparison ### AI Intelligent Refinement Mode **Advantages:** - More precise and refined content - Clearer logical structure - More professional expression - Automatic overview and summary generation **Requirements:** - Valid DeepSeek API key - Internet connection - API call quota ### Basic Extraction Mode **Advantages:** - No API key required - Offline usage - Faster processing speed **Limitations:** - Simpler content extraction - Relies on original document structure - Basic overview and summary generation ## Troubleshooting ### Common Issues & Solutions **1. File Not Found Error** text ``` Error: File 'xxx.docx' does not exist! ``` - Check if file path is correct - Ensure file extension is `.docx` **2. Missing Dependencies** text ``` ❌ Missing required libraries: ModuleNotFoundError ``` - Run `pip install python-docx python-pptx requests` **3. API Call Failure** text ``` ❌ API key invalid or expired ``` - Verify API key correctness - Confirm sufficient account balance - Check internet connection **4. Inaccurate Content Recognition** - Ensure document uses standard heading styles - Check document structure clarity - Try AI mode for better results **5. Generated PPT Format Issues** - Ensure Microsoft PowerPoint is installed - Check file permissions - Try running as administrator ### Debugging Suggestions 1. **Check Console Output**: Program displays detailed processing progress and error messages 2. **Verify Document Structure**: Test with simple sample documents 3. **Step-by-Step Testing**: Start with basic mode, then try AI mode 4. **Review Generation Logs**: Program outputs analysis results and slide counts ## Advanced Usage ### Custom Modifications **Adjust Slide Layout**: python ``` def _create_content_slide(self, prs, section, key_points): # Modify font size, color, layout, etc. p.font.size = Pt(18) # Adjust font size p.font.color.rgb = RGBColor(0, 0, 0) # Adjust font color ``` **Add Company Logo**: python ``` def _create_title_slide(self, prs, title): # Add logo to cover page logo_path = "company_logo.png" left = Inches(1) top = Inches(1) slide.shapes.add_picture(logo_path, left, top, width=Inches(1.5)) ``` ### Batch Processing Modify code for batch document processing: python ``` def batch_convert(docx_folder): for file in os.listdir(docx_folder): if file.endswith('.docx'): docx_path = os.path.join(docx_folder, file) converter.convert(docx_path) ``` ## Technical Support ### Getting Help When encountering issues, please provide: 1. Complete error message from program execution 2. Sample document used (if possible) 3. Operating system and Python version 4. Mode used (Basic/AI) ### Version Information - Current Version: v1.0 - Last Updated: 2024 - Compatibility: Python 3.7+ ## Disclaimer 1. This tool is an auxiliary utility; generated content requires manual review 2. API usage must comply with relevant service terms 3. Document content copyright belongs to original authors 4. No guarantee for accuracy of generated content ------ **Get Started**: Run `python apidoc2ppt.py` and follow the prompts! **Enjoy using the tool!** 🎉