working-with-documentslisted
Install: claude install-skill aiskillstore/marketplace
# Working with Documents
## Quick Reference
| Format | Read | Create | Edit |
|--------|------|--------|------|
| DOCX | pandoc, python-docx | docx-js | OOXML (unpack/edit/pack) |
| PDF | pdfplumber, pypdf | reportlab | pypdf (merge/split) |
| PPTX | markitdown | html2pptx | OOXML (unpack/edit/pack) |
## Word Documents (.docx)
### Reading Content
```bash
# Convert to markdown (preserves structure)
pandoc document.docx -o output.md
# With tracked changes visible
pandoc --track-changes=all document.docx -o output.md
```
### Creating New Documents
Use **docx-js** (JavaScript):
```javascript
const { Document, Packer, Paragraph, TextRun } = require('docx');
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new TextRun({ text: "Hello World", bold: true }),
],
}),
],
}],
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("output.docx", buffer);
});
```
### Editing Existing Documents (Tracked Changes)
```bash
# 1. Unpack
python ooxml/scripts/unpack.py document.docx unpacked/
# 2. Edit XML files in unpacked/word/document.xml
# Key files:
# - word/document.xml (main content)
# - word/comments.xml (comments)
# - word/media/ (images)
# 3. Pack
python ooxml/scripts/pack.py unpacked/ edited.docx
```
**Tracked changes XML pattern:**
```xml
<!-- Deletion -->
<w:del><w:r><w:delText>old text</w:delText></w:r></w:del>