document-processing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Document Processing Guide

文档处理指南

Work with office documents: PDF, Excel, Word, and PowerPoint.

处理办公文档:PDF、Excel、Word和PowerPoint。

Format Overview

格式概述

FormatExtensionStructureBest For
PDF.pdfBinary/textReports, forms, archives
Excel.xlsxXML in ZIPData, calculations, models
Word.docxXML in ZIPText documents, contracts
PowerPoint.pptxXML in ZIPPresentations, slides
Key concept: XLSX, DOCX, and PPTX are all ZIP archives containing XML files. You can unzip them to access raw content.

格式扩展名结构最佳用途
PDF.pdf二进制/文本报告、表单、归档
Excel.xlsxZIP包内的XML文件数据、计算、模型
Word.docxZIP包内的XML文件文本文档、合同
PowerPoint.pptxZIP包内的XML文件演示文稿、幻灯片
核心概念:XLSX、DOCX和PPTX都是包含XML文件的ZIP压缩包,你可以解压它们以访问原始内容。

PDF Processing

PDF处理

PDF Tools

PDF工具

TaskBest Tool
Basic read/writepypdf
Text extractionpdfplumber
Table extractionpdfplumber
Create PDFsreportlab
OCR scanned PDFspytesseract + pdf2image
Command lineqpdf, pdftotext
任务最佳工具
基础读写pypdf
文本提取pdfplumber
表格提取pdfplumber
创建PDFreportlab
扫描版PDF的OCR识别pytesseract + pdf2image
命令行工具qpdf, pdftotext

Common Operations

常见操作

OperationApproach
MergeLoop through files, add pages to writer
SplitCreate new writer per page
Extract tablesUse pdfplumber, convert to DataFrame
RotateCall
.rotate(degrees)
on page
EncryptUse writer's
.encrypt()
method
OCRConvert to images, run pytesseract

操作实现方法
合并遍历文件,将页面添加到写入器
拆分为每个页面创建新的写入器
提取表格使用pdfplumber,转换为DataFrame
旋转对页面调用
.rotate(degrees)
方法
加密使用写入器的
.encrypt()
方法
OCR识别转换为图片,运行pytesseract

Excel Processing

Excel处理

Excel Tools

Excel工具

TaskBest Tool
Data analysispandas
Formulas & formattingopenpyxl
Simple CSVpandas
Financial modelsopenpyxl
任务最佳工具
数据分析pandas
公式与格式设置openpyxl
简单CSV处理pandas
财务模型构建openpyxl

Critical Rule: Use Formulas

重要规则:使用公式

ApproachResult
Wrong: Calculate in Python, write valueStatic number, breaks when data changes
Right: Write Excel formulaDynamic, recalculates automatically
做法结果
错误:在Python中计算,写入数值静态数字,数据变化时失效
正确:写入Excel公式动态计算,会自动重新计算

Financial Model Standards

财务模型标准

ConventionMeaning
Blue textHardcoded inputs
Black textFormulas
Green textLinks to other sheets
Yellow fillNeeds attention
惯例含义
蓝色文本硬编码输入值
黑色文本公式
绿色文本链接到其他工作表
黄色填充需要关注的内容

Common Formula Errors

常见公式错误

ErrorCause
#REF!Invalid cell reference
#DIV/0!Division by zero
#VALUE!Wrong data type
#NAME?Unknown function name

错误代码原因
#REF!无效单元格引用
#DIV/0!除以零
#VALUE!数据类型错误
#NAME?未知函数名称

Word Processing

Word处理

Word Tools

Word工具

TaskBest Tool
Text extractionpandoc
Create newpython-docx or docx-js
Simple editspython-docx
Tracked changesDirect XML editing
任务最佳工具
文本提取pandoc
创建新文档python-docx 或 docx-js
简单编辑python-docx
修订模式处理直接编辑XML

Document Structure

文档结构

FileContains
word/document.xml
Main content
word/comments.xml
Comments
word/media/
Images
文件路径包含内容
word/document.xml
主要内容
word/comments.xml
批注
word/media/
图片

Tracked Changes (Redlining)

修订模式(红线标注)

ElementXML Tag
Deletion
<w:del><w:delText>...</w:delText></w:del>
Insertion
<w:ins><w:t>...</w:t></w:ins>
Key concept: For professional/legal documents, use tracked changes XML rather than replacing text directly.

元素XML标签
删除内容
<w:del><w:delText>...</w:delText></w:del>
插入内容
<w:ins><w:t>...</w:t></w:ins>
核心概念:对于专业/法律类文档,使用修订模式XML而非直接替换文本。

PowerPoint Processing

PowerPoint处理

PowerPoint Tools

PowerPoint工具

TaskBest Tool
Text extractionmarkitdown
Create newpptxgenjs (JS) or python-pptx
Edit existingDirect XML or python-pptx
任务最佳工具
文本提取markitdown
创建新演示文稿pptxgenjs(JS)或 python-pptx
编辑现有演示文稿直接编辑XML 或 python-pptx

Slide Structure

幻灯片结构

PathContains
ppt/slides/slide{N}.xml
Slide content
ppt/notesSlides/
Speaker notes
ppt/slideMasters/
Master templates
ppt/media/
Images
路径包含内容
ppt/slides/slide{N}.xml
幻灯片内容
ppt/notesSlides/
演讲者备注
ppt/slideMasters/
母版模板
ppt/media/
图片

Design Principles

设计原则

PrincipleGuideline
FontsUse web-safe: Arial, Helvetica, Georgia
LayoutTwo-column preferred, avoid vertical stacking
HierarchySize, weight, color for emphasis
ConsistencyRepeat patterns across slides

原则指南
字体使用网页安全字体:Arial、Helvetica、Georgia
布局首选两栏布局,避免垂直堆叠
层级通过字号、字重、颜色强调重点
一致性跨幻灯片重复使用统一样式

Converting Between Formats

格式转换

ConversionTool
Any → PDFLibreOffice headless
PDF → Imagespdftoppm
DOCX → Markdownpandoc
Any → TextAppropriate extractor

转换方向工具
任意格式 → PDFLibreOffice headless
PDF → 图片pdftoppm
DOCX → Markdownpandoc
任意格式 → 文本对应格式的提取工具

Best Practices

最佳实践

PracticeWhy
Use formulas in ExcelDynamic calculations
Preserve formatting on editDon't lose styles
Test output opens correctlyCatch corruption early
Use tracked changes for contractsAudit trail
Extract to markdown for analysisEasier to process
实践原因
在Excel中使用公式实现动态计算
编辑时保留格式避免丢失样式
测试输出文件能否正常打开尽早发现文件损坏问题
合同类文档使用修订模式保留审计追踪痕迹
提取为Markdown格式进行分析更易于处理

Common Packages

常用工具包

LanguagePackages
Pythonpypdf, pdfplumber, openpyxl, python-docx, python-pptx
JavaScriptdocx, pptxgenjs
CLIpandoc, qpdf, pdftotext, libreoffice
语言工具包
Pythonpypdf, pdfplumber, openpyxl, python-docx, python-pptx
JavaScriptdocx, pptxgenjs
命令行pandoc, qpdf, pdftotext, libreoffice