daemora 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE +663 -0
  2. package/README.md +69 -19
  3. package/SOUL.md +25 -24
  4. package/daemora-ui/README.md +11 -0
  5. package/package.json +12 -2
  6. package/skills/api-development.md +35 -0
  7. package/skills/artifacts-builder/SKILL.md +74 -0
  8. package/skills/artifacts-builder/scripts/bundle-artifact.sh +54 -0
  9. package/skills/artifacts-builder/scripts/init-artifact.sh +322 -0
  10. package/skills/artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  11. package/skills/brand-guidelines.md +73 -0
  12. package/skills/browser.md +77 -0
  13. package/skills/changelog-generator.md +104 -0
  14. package/skills/coding.md +26 -10
  15. package/skills/content-research-writer.md +538 -0
  16. package/skills/data-analysis.md +27 -0
  17. package/skills/debugging.md +33 -0
  18. package/skills/devops.md +37 -0
  19. package/skills/document-docx.md +197 -0
  20. package/skills/document-pdf.md +294 -0
  21. package/skills/document-pptx.md +484 -0
  22. package/skills/document-xlsx.md +289 -0
  23. package/skills/domain-name-brainstormer.md +212 -0
  24. package/skills/file-organizer.md +433 -0
  25. package/skills/frontend-design.md +42 -0
  26. package/skills/image-enhancer.md +99 -0
  27. package/skills/invoice-organizer.md +446 -0
  28. package/skills/lead-research-assistant.md +199 -0
  29. package/skills/mcp-builder/SKILL.md +328 -0
  30. package/skills/mcp-builder/reference/evaluation.md +602 -0
  31. package/skills/mcp-builder/reference/mcp_best_practices.md +915 -0
  32. package/skills/mcp-builder/reference/node_mcp_server.md +916 -0
  33. package/skills/mcp-builder/reference/python_mcp_server.md +752 -0
  34. package/skills/mcp-builder/scripts/connections.py +151 -0
  35. package/skills/mcp-builder/scripts/evaluation.py +373 -0
  36. package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  37. package/skills/mcp-builder/scripts/requirements.txt +2 -0
  38. package/skills/meeting-insights-analyzer.md +327 -0
  39. package/skills/orchestration.md +93 -0
  40. package/skills/raffle-winner-picker.md +159 -0
  41. package/skills/slack-gif-creator/SKILL.md +646 -0
  42. package/skills/slack-gif-creator/core/color_palettes.py +302 -0
  43. package/skills/slack-gif-creator/core/easing.py +230 -0
  44. package/skills/slack-gif-creator/core/frame_composer.py +469 -0
  45. package/skills/slack-gif-creator/core/gif_builder.py +246 -0
  46. package/skills/slack-gif-creator/core/typography.py +357 -0
  47. package/skills/slack-gif-creator/core/validators.py +264 -0
  48. package/skills/slack-gif-creator/core/visual_effects.py +494 -0
  49. package/skills/slack-gif-creator/requirements.txt +4 -0
  50. package/skills/slack-gif-creator/templates/bounce.py +106 -0
  51. package/skills/slack-gif-creator/templates/explode.py +331 -0
  52. package/skills/slack-gif-creator/templates/fade.py +329 -0
  53. package/skills/slack-gif-creator/templates/flip.py +291 -0
  54. package/skills/slack-gif-creator/templates/kaleidoscope.py +211 -0
  55. package/skills/slack-gif-creator/templates/morph.py +329 -0
  56. package/skills/slack-gif-creator/templates/move.py +293 -0
  57. package/skills/slack-gif-creator/templates/pulse.py +268 -0
  58. package/skills/slack-gif-creator/templates/shake.py +127 -0
  59. package/skills/slack-gif-creator/templates/slide.py +291 -0
  60. package/skills/slack-gif-creator/templates/spin.py +269 -0
  61. package/skills/slack-gif-creator/templates/wiggle.py +300 -0
  62. package/skills/slack-gif-creator/templates/zoom.py +312 -0
  63. package/skills/system-admin.md +44 -0
  64. package/skills/tailored-resume-generator.md +345 -0
  65. package/skills/theme-factory/SKILL.md +59 -0
  66. package/skills/theme-factory/theme-showcase.pdf +0 -0
  67. package/skills/theme-factory/themes/arctic-frost.md +19 -0
  68. package/skills/theme-factory/themes/botanical-garden.md +19 -0
  69. package/skills/theme-factory/themes/desert-rose.md +19 -0
  70. package/skills/theme-factory/themes/forest-canopy.md +19 -0
  71. package/skills/theme-factory/themes/golden-hour.md +19 -0
  72. package/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  73. package/skills/theme-factory/themes/modern-minimalist.md +19 -0
  74. package/skills/theme-factory/themes/ocean-depths.md +19 -0
  75. package/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  76. package/skills/theme-factory/themes/tech-innovation.md +19 -0
  77. package/skills/video-downloader.md +99 -0
  78. package/skills/web-development.md +32 -0
  79. package/skills/webapp-testing/SKILL.md +96 -0
  80. package/skills/webapp-testing/examples/console_logging.py +35 -0
  81. package/skills/webapp-testing/examples/element_discovery.py +40 -0
  82. package/skills/webapp-testing/examples/static_html_automation.py +33 -0
  83. package/skills/webapp-testing/scripts/with_server.py +106 -0
  84. package/src/agents/SubAgentManager.js +57 -12
  85. package/src/api/openai-compat.js +212 -0
  86. package/src/channels/TelegramChannel.js +5 -2
  87. package/src/channels/index.js +7 -10
  88. package/src/cli.js +129 -50
  89. package/src/config/agentProfiles.js +1 -0
  90. package/src/config/default.js +10 -0
  91. package/src/config/models.js +317 -71
  92. package/src/config/permissions.js +12 -0
  93. package/src/core/AgentLoop.js +70 -50
  94. package/src/core/Compaction.js +84 -2
  95. package/src/core/MessageQueue.js +90 -0
  96. package/src/core/Task.js +13 -0
  97. package/src/core/TaskQueue.js +1 -1
  98. package/src/core/TaskRunner.js +80 -5
  99. package/src/index.js +328 -48
  100. package/src/mcp/MCPAgentRunner.js +48 -11
  101. package/src/mcp/MCPManager.js +40 -2
  102. package/src/models/ModelRouter.js +67 -1
  103. package/src/safety/DockerSandbox.js +212 -0
  104. package/src/safety/ExecApproval.js +118 -0
  105. package/src/scheduler/Heartbeat.js +56 -21
  106. package/src/services/cleanup.js +106 -0
  107. package/src/services/sessions.js +39 -1
  108. package/src/setup/wizard.js +75 -4
  109. package/src/skills/SkillLoader.js +104 -17
  110. package/src/storage/TaskStore.js +19 -1
  111. package/src/systemPrompt.js +171 -328
  112. package/src/tools/browserAutomation.js +615 -104
  113. package/src/tools/executeCommand.js +19 -1
  114. package/src/tools/index.js +6 -0
  115. package/src/tools/manageAgents.js +55 -4
  116. package/src/tools/replyWithFile.js +62 -0
  117. package/src/tools/screenCapture.js +12 -1
  118. package/src/tools/taskManager.js +164 -0
  119. package/src/tools/useMCP.js +3 -1
  120. package/src/utils/Embeddings.js +157 -10
  121. package/src/webhooks/WebhookHandler.js +107 -0
@@ -0,0 +1,197 @@
1
+ ---
2
+ name: docx
3
+ description: "Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks"
4
+ license: Proprietary. LICENSE.txt has complete terms
5
+ ---
6
+
7
+ # DOCX creation, editing, and analysis
8
+
9
+ ## Overview
10
+
11
+ A user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.
12
+
13
+ ## Workflow Decision Tree
14
+
15
+ ### Reading/Analyzing Content
16
+ Use "Text extraction" or "Raw XML access" sections below
17
+
18
+ ### Creating New Document
19
+ Use "Creating a new Word document" workflow
20
+
21
+ ### Editing Existing Document
22
+ - **Your own document + simple changes**
23
+ Use "Basic OOXML editing" workflow
24
+
25
+ - **Someone else's document**
26
+ Use **"Redlining workflow"** (recommended default)
27
+
28
+ - **Legal, academic, business, or government docs**
29
+ Use **"Redlining workflow"** (required)
30
+
31
+ ## Reading and analyzing content
32
+
33
+ ### Text extraction
34
+ If you just need to read the text contents of a document, you should convert the document to markdown using pandoc. Pandoc provides excellent support for preserving document structure and can show tracked changes:
35
+
36
+ ```bash
37
+ # Convert document to markdown with tracked changes
38
+ pandoc --track-changes=all path-to-file.docx -o output.md
39
+ # Options: --track-changes=accept/reject/all
40
+ ```
41
+
42
+ ### Raw XML access
43
+ You need raw XML access for: comments, complex formatting, document structure, embedded media, and metadata. For any of these features, you'll need to unpack a document and read its raw XML contents.
44
+
45
+ #### Unpacking a file
46
+ `python ooxml/scripts/unpack.py <office_file> <output_directory>`
47
+
48
+ #### Key file structures
49
+ * `word/document.xml` - Main document contents
50
+ * `word/comments.xml` - Comments referenced in document.xml
51
+ * `word/media/` - Embedded images and media files
52
+ * Tracked changes use `<w:ins>` (insertions) and `<w:del>` (deletions) tags
53
+
54
+ ## Creating a new Word document
55
+
56
+ When creating a new Word document from scratch, use **docx-js**, which allows you to create Word documents using JavaScript/TypeScript.
57
+
58
+ ### Workflow
59
+ 1. **MANDATORY - READ ENTIRE FILE**: Read [`docx-js.md`](docx-js.md) (~500 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with document creation.
60
+ 2. Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components (You can assume all dependencies are installed, but if not, refer to the dependencies section below)
61
+ 3. Export as .docx using Packer.toBuffer()
62
+
63
+ ## Editing an existing Word document
64
+
65
+ When editing an existing Word document, use the **Document library** (a Python library for OOXML manipulation). The library automatically handles infrastructure setup and provides methods for document manipulation. For complex scenarios, you can access the underlying DOM directly through the library.
66
+
67
+ ### Workflow
68
+ 1. **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for the Document library API and XML patterns for directly editing document files.
69
+ 2. Unpack the document: `python ooxml/scripts/unpack.py <office_file> <output_directory>`
70
+ 3. Create and run a Python script using the Document library (see "Document Library" section in ooxml.md)
71
+ 4. Pack the final document: `python ooxml/scripts/pack.py <input_directory> <office_file>`
72
+
73
+ The Document library provides both high-level methods for common operations and direct DOM access for complex scenarios.
74
+
75
+ ## Redlining workflow for document review
76
+
77
+ This workflow allows you to plan comprehensive tracked changes using markdown before implementing them in OOXML. **CRITICAL**: For complete tracked changes, you must implement ALL changes systematically.
78
+
79
+ **Batching Strategy**: Group related changes into batches of 3-10 changes. This makes debugging manageable while maintaining efficiency. Test each batch before moving to the next.
80
+
81
+ **Principle: Minimal, Precise Edits**
82
+ When implementing tracked changes, only mark text that actually changes. Repeating unchanged text makes edits harder to review and appears unprofessional. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text]. Preserve the original run's RSID for unchanged text by extracting the `<w:r>` element from the original and reusing it.
83
+
84
+ Example - Changing "30 days" to "60 days" in a sentence:
85
+ ```python
86
+ # BAD - Replaces entire sentence
87
+ '<w:del><w:r><w:delText>The term is 30 days.</w:delText></w:r></w:del><w:ins><w:r><w:t>The term is 60 days.</w:t></w:r></w:ins>'
88
+
89
+ # GOOD - Only marks what changed, preserves original <w:r> for unchanged text
90
+ '<w:r w:rsidR="00AB12CD"><w:t>The term is </w:t></w:r><w:del><w:r><w:delText>30</w:delText></w:r></w:del><w:ins><w:r><w:t>60</w:t></w:r></w:ins><w:r w:rsidR="00AB12CD"><w:t> days.</w:t></w:r>'
91
+ ```
92
+
93
+ ### Tracked changes workflow
94
+
95
+ 1. **Get markdown representation**: Convert document to markdown with tracked changes preserved:
96
+ ```bash
97
+ pandoc --track-changes=all path-to-file.docx -o current.md
98
+ ```
99
+
100
+ 2. **Identify and group changes**: Review the document and identify ALL changes needed, organizing them into logical batches:
101
+
102
+ **Location methods** (for finding changes in XML):
103
+ - Section/heading numbers (e.g., "Section 3.2", "Article IV")
104
+ - Paragraph identifiers if numbered
105
+ - Grep patterns with unique surrounding text
106
+ - Document structure (e.g., "first paragraph", "signature block")
107
+ - **DO NOT use markdown line numbers** - they don't map to XML structure
108
+
109
+ **Batch organization** (group 3-10 related changes per batch):
110
+ - By section: "Batch 1: Section 2 amendments", "Batch 2: Section 5 updates"
111
+ - By type: "Batch 1: Date corrections", "Batch 2: Party name changes"
112
+ - By complexity: Start with simple text replacements, then tackle complex structural changes
113
+ - Sequential: "Batch 1: Pages 1-3", "Batch 2: Pages 4-6"
114
+
115
+ 3. **Read documentation and unpack**:
116
+ - **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Pay special attention to the "Document Library" and "Tracked Change Patterns" sections.
117
+ - **Unpack the document**: `python ooxml/scripts/unpack.py <file.docx> <dir>`
118
+ - **Note the suggested RSID**: The unpack script will suggest an RSID to use for your tracked changes. Copy this RSID for use in step 4b.
119
+
120
+ 4. **Implement changes in batches**: Group changes logically (by section, by type, or by proximity) and implement them together in a single script. This approach:
121
+ - Makes debugging easier (smaller batch = easier to isolate errors)
122
+ - Allows incremental progress
123
+ - Maintains efficiency (batch size of 3-10 changes works well)
124
+
125
+ **Suggested batch groupings:**
126
+ - By document section (e.g., "Section 3 changes", "Definitions", "Termination clause")
127
+ - By change type (e.g., "Date changes", "Party name updates", "Legal term replacements")
128
+ - By proximity (e.g., "Changes on pages 1-3", "Changes in first half of document")
129
+
130
+ For each batch of related changes:
131
+
132
+ **a. Map text to XML**: Grep for text in `word/document.xml` to verify how text is split across `<w:r>` elements.
133
+
134
+ **b. Create and run script**: Use `get_node` to find nodes, implement changes, then `doc.save()`. See **"Document Library"** section in ooxml.md for patterns.
135
+
136
+ **Note**: Always grep `word/document.xml` immediately before writing a script to get current line numbers and verify text content. Line numbers change after each script run.
137
+
138
+ 5. **Pack the document**: After all batches are complete, convert the unpacked directory back to .docx:
139
+ ```bash
140
+ python ooxml/scripts/pack.py unpacked reviewed-document.docx
141
+ ```
142
+
143
+ 6. **Final verification**: Do a comprehensive check of the complete document:
144
+ - Convert final document to markdown:
145
+ ```bash
146
+ pandoc --track-changes=all reviewed-document.docx -o verification.md
147
+ ```
148
+ - Verify ALL changes were applied correctly:
149
+ ```bash
150
+ grep "original phrase" verification.md # Should NOT find it
151
+ grep "replacement phrase" verification.md # Should find it
152
+ ```
153
+ - Check that no unintended changes were introduced
154
+
155
+
156
+ ## Converting Documents to Images
157
+
158
+ To visually analyze Word documents, convert them to images using a two-step process:
159
+
160
+ 1. **Convert DOCX to PDF**:
161
+ ```bash
162
+ soffice --headless --convert-to pdf document.docx
163
+ ```
164
+
165
+ 2. **Convert PDF pages to JPEG images**:
166
+ ```bash
167
+ pdftoppm -jpeg -r 150 document.pdf page
168
+ ```
169
+ This creates files like `page-1.jpg`, `page-2.jpg`, etc.
170
+
171
+ Options:
172
+ - `-r 150`: Sets resolution to 150 DPI (adjust for quality/size balance)
173
+ - `-jpeg`: Output JPEG format (use `-png` for PNG if preferred)
174
+ - `-f N`: First page to convert (e.g., `-f 2` starts from page 2)
175
+ - `-l N`: Last page to convert (e.g., `-l 5` stops at page 5)
176
+ - `page`: Prefix for output files
177
+
178
+ Example for specific range:
179
+ ```bash
180
+ pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page # Converts only pages 2-5
181
+ ```
182
+
183
+ ## Code Style Guidelines
184
+ **IMPORTANT**: When generating code for DOCX operations:
185
+ - Write concise code
186
+ - Avoid verbose variable names and redundant operations
187
+ - Avoid unnecessary print statements
188
+
189
+ ## Dependencies
190
+
191
+ Required dependencies (install if not available):
192
+
193
+ - **pandoc**: `sudo apt-get install pandoc` (for text extraction)
194
+ - **docx**: `npm install -g docx` (for creating new documents)
195
+ - **LibreOffice**: `sudo apt-get install libreoffice` (for PDF conversion)
196
+ - **Poppler**: `sudo apt-get install poppler-utils` (for pdftoppm to convert PDF to images)
197
+ - **defusedxml**: `pip install defusedxml` (for secure XML parsing)
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: pdf
3
+ description: Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
4
+ license: Proprietary. LICENSE.txt has complete terms
5
+ ---
6
+
7
+ # PDF Processing Guide
8
+
9
+ ## Overview
10
+
11
+ This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see reference.md. If you need to fill out a PDF form, read forms.md and follow its instructions.
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ from pypdf import PdfReader, PdfWriter
17
+
18
+ # Read a PDF
19
+ reader = PdfReader("document.pdf")
20
+ print(f"Pages: {len(reader.pages)}")
21
+
22
+ # Extract text
23
+ text = ""
24
+ for page in reader.pages:
25
+ text += page.extract_text()
26
+ ```
27
+
28
+ ## Python Libraries
29
+
30
+ ### pypdf - Basic Operations
31
+
32
+ #### Merge PDFs
33
+ ```python
34
+ from pypdf import PdfWriter, PdfReader
35
+
36
+ writer = PdfWriter()
37
+ for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
38
+ reader = PdfReader(pdf_file)
39
+ for page in reader.pages:
40
+ writer.add_page(page)
41
+
42
+ with open("merged.pdf", "wb") as output:
43
+ writer.write(output)
44
+ ```
45
+
46
+ #### Split PDF
47
+ ```python
48
+ reader = PdfReader("input.pdf")
49
+ for i, page in enumerate(reader.pages):
50
+ writer = PdfWriter()
51
+ writer.add_page(page)
52
+ with open(f"page_{i+1}.pdf", "wb") as output:
53
+ writer.write(output)
54
+ ```
55
+
56
+ #### Extract Metadata
57
+ ```python
58
+ reader = PdfReader("document.pdf")
59
+ meta = reader.metadata
60
+ print(f"Title: {meta.title}")
61
+ print(f"Author: {meta.author}")
62
+ print(f"Subject: {meta.subject}")
63
+ print(f"Creator: {meta.creator}")
64
+ ```
65
+
66
+ #### Rotate Pages
67
+ ```python
68
+ reader = PdfReader("input.pdf")
69
+ writer = PdfWriter()
70
+
71
+ page = reader.pages[0]
72
+ page.rotate(90) # Rotate 90 degrees clockwise
73
+ writer.add_page(page)
74
+
75
+ with open("rotated.pdf", "wb") as output:
76
+ writer.write(output)
77
+ ```
78
+
79
+ ### pdfplumber - Text and Table Extraction
80
+
81
+ #### Extract Text with Layout
82
+ ```python
83
+ import pdfplumber
84
+
85
+ with pdfplumber.open("document.pdf") as pdf:
86
+ for page in pdf.pages:
87
+ text = page.extract_text()
88
+ print(text)
89
+ ```
90
+
91
+ #### Extract Tables
92
+ ```python
93
+ with pdfplumber.open("document.pdf") as pdf:
94
+ for i, page in enumerate(pdf.pages):
95
+ tables = page.extract_tables()
96
+ for j, table in enumerate(tables):
97
+ print(f"Table {j+1} on page {i+1}:")
98
+ for row in table:
99
+ print(row)
100
+ ```
101
+
102
+ #### Advanced Table Extraction
103
+ ```python
104
+ import pandas as pd
105
+
106
+ with pdfplumber.open("document.pdf") as pdf:
107
+ all_tables = []
108
+ for page in pdf.pages:
109
+ tables = page.extract_tables()
110
+ for table in tables:
111
+ if table: # Check if table is not empty
112
+ df = pd.DataFrame(table[1:], columns=table[0])
113
+ all_tables.append(df)
114
+
115
+ # Combine all tables
116
+ if all_tables:
117
+ combined_df = pd.concat(all_tables, ignore_index=True)
118
+ combined_df.to_excel("extracted_tables.xlsx", index=False)
119
+ ```
120
+
121
+ ### reportlab - Create PDFs
122
+
123
+ #### Basic PDF Creation
124
+ ```python
125
+ from reportlab.lib.pagesizes import letter
126
+ from reportlab.pdfgen import canvas
127
+
128
+ c = canvas.Canvas("hello.pdf", pagesize=letter)
129
+ width, height = letter
130
+
131
+ # Add text
132
+ c.drawString(100, height - 100, "Hello World!")
133
+ c.drawString(100, height - 120, "This is a PDF created with reportlab")
134
+
135
+ # Add a line
136
+ c.line(100, height - 140, 400, height - 140)
137
+
138
+ # Save
139
+ c.save()
140
+ ```
141
+
142
+ #### Create PDF with Multiple Pages
143
+ ```python
144
+ from reportlab.lib.pagesizes import letter
145
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
146
+ from reportlab.lib.styles import getSampleStyleSheet
147
+
148
+ doc = SimpleDocTemplate("report.pdf", pagesize=letter)
149
+ styles = getSampleStyleSheet()
150
+ story = []
151
+
152
+ # Add content
153
+ title = Paragraph("Report Title", styles['Title'])
154
+ story.append(title)
155
+ story.append(Spacer(1, 12))
156
+
157
+ body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
158
+ story.append(body)
159
+ story.append(PageBreak())
160
+
161
+ # Page 2
162
+ story.append(Paragraph("Page 2", styles['Heading1']))
163
+ story.append(Paragraph("Content for page 2", styles['Normal']))
164
+
165
+ # Build PDF
166
+ doc.build(story)
167
+ ```
168
+
169
+ ## Command-Line Tools
170
+
171
+ ### pdftotext (poppler-utils)
172
+ ```bash
173
+ # Extract text
174
+ pdftotext input.pdf output.txt
175
+
176
+ # Extract text preserving layout
177
+ pdftotext -layout input.pdf output.txt
178
+
179
+ # Extract specific pages
180
+ pdftotext -f 1 -l 5 input.pdf output.txt # Pages 1-5
181
+ ```
182
+
183
+ ### qpdf
184
+ ```bash
185
+ # Merge PDFs
186
+ qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf
187
+
188
+ # Split pages
189
+ qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
190
+ qpdf input.pdf --pages . 6-10 -- pages6-10.pdf
191
+
192
+ # Rotate pages
193
+ qpdf input.pdf output.pdf --rotate=+90:1 # Rotate page 1 by 90 degrees
194
+
195
+ # Remove password
196
+ qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf
197
+ ```
198
+
199
+ ### pdftk (if available)
200
+ ```bash
201
+ # Merge
202
+ pdftk file1.pdf file2.pdf cat output merged.pdf
203
+
204
+ # Split
205
+ pdftk input.pdf burst
206
+
207
+ # Rotate
208
+ pdftk input.pdf rotate 1east output rotated.pdf
209
+ ```
210
+
211
+ ## Common Tasks
212
+
213
+ ### Extract Text from Scanned PDFs
214
+ ```python
215
+ # Requires: pip install pytesseract pdf2image
216
+ import pytesseract
217
+ from pdf2image import convert_from_path
218
+
219
+ # Convert PDF to images
220
+ images = convert_from_path('scanned.pdf')
221
+
222
+ # OCR each page
223
+ text = ""
224
+ for i, image in enumerate(images):
225
+ text += f"Page {i+1}:\n"
226
+ text += pytesseract.image_to_string(image)
227
+ text += "\n\n"
228
+
229
+ print(text)
230
+ ```
231
+
232
+ ### Add Watermark
233
+ ```python
234
+ from pypdf import PdfReader, PdfWriter
235
+
236
+ # Create watermark (or load existing)
237
+ watermark = PdfReader("watermark.pdf").pages[0]
238
+
239
+ # Apply to all pages
240
+ reader = PdfReader("document.pdf")
241
+ writer = PdfWriter()
242
+
243
+ for page in reader.pages:
244
+ page.merge_page(watermark)
245
+ writer.add_page(page)
246
+
247
+ with open("watermarked.pdf", "wb") as output:
248
+ writer.write(output)
249
+ ```
250
+
251
+ ### Extract Images
252
+ ```bash
253
+ # Using pdfimages (poppler-utils)
254
+ pdfimages -j input.pdf output_prefix
255
+
256
+ # This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.
257
+ ```
258
+
259
+ ### Password Protection
260
+ ```python
261
+ from pypdf import PdfReader, PdfWriter
262
+
263
+ reader = PdfReader("input.pdf")
264
+ writer = PdfWriter()
265
+
266
+ for page in reader.pages:
267
+ writer.add_page(page)
268
+
269
+ # Add password
270
+ writer.encrypt("userpassword", "ownerpassword")
271
+
272
+ with open("encrypted.pdf", "wb") as output:
273
+ writer.write(output)
274
+ ```
275
+
276
+ ## Quick Reference
277
+
278
+ | Task | Best Tool | Command/Code |
279
+ |------|-----------|--------------|
280
+ | Merge PDFs | pypdf | `writer.add_page(page)` |
281
+ | Split PDFs | pypdf | One page per file |
282
+ | Extract text | pdfplumber | `page.extract_text()` |
283
+ | Extract tables | pdfplumber | `page.extract_tables()` |
284
+ | Create PDFs | reportlab | Canvas or Platypus |
285
+ | Command line merge | qpdf | `qpdf --empty --pages ...` |
286
+ | OCR scanned PDFs | pytesseract | Convert to image first |
287
+ | Fill PDF forms | pdf-lib or pypdf (see forms.md) | See forms.md |
288
+
289
+ ## Next Steps
290
+
291
+ - For advanced pypdfium2 usage, see reference.md
292
+ - For JavaScript libraries (pdf-lib), see reference.md
293
+ - If you need to fill out a PDF form, follow the instructions in forms.md
294
+ - For troubleshooting guides, see reference.md