hive-skills 0.1.0

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 (238) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +235 -0
  3. package/assets/LICENSE +32 -0
  4. package/assets/THIRD_PARTY_NOTICES.md +72 -0
  5. package/assets/manifest.json +1290 -0
  6. package/assets/skills/authored/code-review/composable/BUNDLE.md +192 -0
  7. package/assets/skills/authored/code-review/composable/INDEX.md +13 -0
  8. package/assets/skills/authored/code-review/composable/VERSION +1 -0
  9. package/assets/skills/authored/code-review/composable/mini/01-review-method.md +34 -0
  10. package/assets/skills/authored/code-review/composable/mini/02-security-review.md +20 -0
  11. package/assets/skills/authored/code-review/composable/mini/03-correctness-bugs.md +19 -0
  12. package/assets/skills/authored/code-review/composable/mini/04-concurrency.md +16 -0
  13. package/assets/skills/authored/code-review/composable/mini/05-error-handling.md +12 -0
  14. package/assets/skills/authored/code-review/composable/mini/06-performance.md +11 -0
  15. package/assets/skills/authored/code-review/composable/mini/07-api-design.md +20 -0
  16. package/assets/skills/authored/code-review/composable/mini/08-missing-tests.md +25 -0
  17. package/assets/skills/authored/code-review/composable/mini/09-refactoring-and-communication.md +32 -0
  18. package/assets/skills/authored/data-analysis/composable/BUNDLE.md +186 -0
  19. package/assets/skills/authored/data-analysis/composable/INDEX.md +13 -0
  20. package/assets/skills/authored/data-analysis/composable/VERSION +1 -0
  21. package/assets/skills/authored/data-analysis/composable/mini/01-data-quality-profiling.md +26 -0
  22. package/assets/skills/authored/data-analysis/composable/mini/02-aggregation-pitfalls.md +21 -0
  23. package/assets/skills/authored/data-analysis/composable/mini/03-time-series.md +19 -0
  24. package/assets/skills/authored/data-analysis/composable/mini/04-segmentation.md +23 -0
  25. package/assets/skills/authored/data-analysis/composable/mini/05-discount-pricing.md +17 -0
  26. package/assets/skills/authored/data-analysis/composable/mini/06-insight-generation.md +25 -0
  27. package/assets/skills/authored/data-analysis/composable/mini/07-executive-writing.md +26 -0
  28. package/assets/skills/authored/data-analysis/composable/mini/08-recommendations.md +20 -0
  29. package/assets/skills/authored/data-analysis/composable/mini/09-reproducibility-assumptions.md +20 -0
  30. package/assets/skills/authored/financial-analysis/composable/BUNDLE.md +1293 -0
  31. package/assets/skills/authored/financial-analysis/composable/INDEX.md +17 -0
  32. package/assets/skills/authored/financial-analysis/composable/VERSION +1 -0
  33. package/assets/skills/authored/financial-analysis/composable/mini/00-core.md +69 -0
  34. package/assets/skills/authored/financial-analysis/composable/mini/01-profitability-efficiency-ratios.md +173 -0
  35. package/assets/skills/authored/financial-analysis/composable/mini/02-liquidity-leverage-ratios.md +120 -0
  36. package/assets/skills/authored/financial-analysis/composable/mini/03-valuation-ratios-interpretation.md +107 -0
  37. package/assets/skills/authored/financial-analysis/composable/mini/04-dcf-projection-wacc.md +122 -0
  38. package/assets/skills/authored/financial-analysis/composable/mini/05-dcf-terminal-value-sensitivity.md +75 -0
  39. package/assets/skills/authored/financial-analysis/composable/mini/06-comparables-precedents.md +78 -0
  40. package/assets/skills/authored/financial-analysis/composable/mini/07-budget-variance-analysis.md +47 -0
  41. package/assets/skills/authored/financial-analysis/composable/mini/08-driver-based-forecasting-scenarios.md +111 -0
  42. package/assets/skills/authored/financial-analysis/composable/mini/09-rolling-forecasts-accuracy.md +114 -0
  43. package/assets/skills/authored/financial-analysis/composable/mini/10-reporting-exec-summary.md +58 -0
  44. package/assets/skills/authored/financial-analysis/composable/mini/11-industry-adaptations.md +130 -0
  45. package/assets/skills/authored/financial-analysis/composable/mini/12-toolkit-scripts-io.md +102 -0
  46. package/assets/skills/authored/python-api/composable/BUNDLE.md +389 -0
  47. package/assets/skills/authored/python-api/composable/INDEX.md +13 -0
  48. package/assets/skills/authored/python-api/composable/VERSION +1 -0
  49. package/assets/skills/authored/python-api/composable/mini/01-project-structure.md +44 -0
  50. package/assets/skills/authored/python-api/composable/mini/02-routing-and-app.md +38 -0
  51. package/assets/skills/authored/python-api/composable/mini/03-pydantic-models.md +45 -0
  52. package/assets/skills/authored/python-api/composable/mini/04-validation-and-errors.md +59 -0
  53. package/assets/skills/authored/python-api/composable/mini/05-dependencies-and-auth.md +60 -0
  54. package/assets/skills/authored/python-api/composable/mini/06-pagination-filtering.md +44 -0
  55. package/assets/skills/authored/python-api/composable/mini/07-async-performance.md +30 -0
  56. package/assets/skills/authored/python-api/composable/mini/08-testing.md +45 -0
  57. package/assets/skills/authored/python-api/composable/mini/09-middleware-observability.md +29 -0
  58. package/assets/skills/authored/tech-writing/composable/BUNDLE.md +220 -0
  59. package/assets/skills/authored/tech-writing/composable/INDEX.md +12 -0
  60. package/assets/skills/authored/tech-writing/composable/VERSION +1 -0
  61. package/assets/skills/authored/tech-writing/composable/mini/01-audience-analysis.md +26 -0
  62. package/assets/skills/authored/tech-writing/composable/mini/02-document-types.md +27 -0
  63. package/assets/skills/authored/tech-writing/composable/mini/03-readme-quickstart-changelog.md +22 -0
  64. package/assets/skills/authored/tech-writing/composable/mini/04-information-architecture.md +21 -0
  65. package/assets/skills/authored/tech-writing/composable/mini/05-style-clarity.md +29 -0
  66. package/assets/skills/authored/tech-writing/composable/mini/06-breaking-changes-migrations.md +33 -0
  67. package/assets/skills/authored/tech-writing/composable/mini/07-troubleshooting-security.md +30 -0
  68. package/assets/skills/authored/tech-writing/composable/mini/08-faq-voice-tone.md +32 -0
  69. package/assets/skills/converted/claude-api/composable/BUNDLE.md +14996 -0
  70. package/assets/skills/converted/claude-api/composable/INDEX.md +98 -0
  71. package/assets/skills/converted/claude-api/composable/VERSION +1 -0
  72. package/assets/skills/converted/claude-api/composable/mini/00-core.md +235 -0
  73. package/assets/skills/converted/claude-api/composable/mini/01-model-api-quick-reference.md +258 -0
  74. package/assets/skills/converted/claude-api/composable/mini/02-common-pitfalls.md +42 -0
  75. package/assets/skills/converted/claude-api/composable/mini/10-models.md +135 -0
  76. package/assets/skills/converted/claude-api/composable/mini/11-platform-availability.md +96 -0
  77. package/assets/skills/converted/claude-api/composable/mini/12-claude-platform-on-aws.md +59 -0
  78. package/assets/skills/converted/claude-api/composable/mini/13-live-sources.md +143 -0
  79. package/assets/skills/converted/claude-api/composable/mini/14-error-codes.md +256 -0
  80. package/assets/skills/converted/claude-api/composable/mini/15-prompt-caching.md +223 -0
  81. package/assets/skills/converted/claude-api/composable/mini/16-token-counting.md +56 -0
  82. package/assets/skills/converted/claude-api/composable/mini/17-tool-use-concepts.md +444 -0
  83. package/assets/skills/converted/claude-api/composable/mini/18-agent-design.md +101 -0
  84. package/assets/skills/converted/claude-api/composable/mini/19-anthropic-cli.md +246 -0
  85. package/assets/skills/converted/claude-api/composable/mini/20-model-migration.md +1301 -0
  86. package/assets/skills/converted/claude-api/composable/mini/30-managed-agents-overview.md +71 -0
  87. package/assets/skills/converted/claude-api/composable/mini/31-managed-agents-core.md +278 -0
  88. package/assets/skills/converted/claude-api/composable/mini/32-managed-agents-environments.md +219 -0
  89. package/assets/skills/converted/claude-api/composable/mini/33-managed-agents-tools.md +366 -0
  90. package/assets/skills/converted/claude-api/composable/mini/34-managed-agents-events.md +252 -0
  91. package/assets/skills/converted/claude-api/composable/mini/35-managed-agents-outcomes.md +106 -0
  92. package/assets/skills/converted/claude-api/composable/mini/36-managed-agents-multiagent.md +101 -0
  93. package/assets/skills/converted/claude-api/composable/mini/37-managed-agents-webhooks.md +123 -0
  94. package/assets/skills/converted/claude-api/composable/mini/38-managed-agents-memory.md +197 -0
  95. package/assets/skills/converted/claude-api/composable/mini/39-managed-agents-scheduled-deployments.md +146 -0
  96. package/assets/skills/converted/claude-api/composable/mini/40-managed-agents-client-patterns.md +211 -0
  97. package/assets/skills/converted/claude-api/composable/mini/41-managed-agents-onboarding.md +82 -0
  98. package/assets/skills/converted/claude-api/composable/mini/42-managed-agents-api-reference.md +441 -0
  99. package/assets/skills/converted/claude-api/composable/mini/43-managed-agents-self-hosted-sandboxes.md +174 -0
  100. package/assets/skills/converted/claude-api/composable/mini/50-python-readme.md +564 -0
  101. package/assets/skills/converted/claude-api/composable/mini/51-python-tool-use.md +590 -0
  102. package/assets/skills/converted/claude-api/composable/mini/52-python-streaming-batches-files.md +549 -0
  103. package/assets/skills/converted/claude-api/composable/mini/53-python-managed-agents.md +335 -0
  104. package/assets/skills/converted/claude-api/composable/mini/55-typescript-readme.md +404 -0
  105. package/assets/skills/converted/claude-api/composable/mini/56-typescript-tool-use.md +548 -0
  106. package/assets/skills/converted/claude-api/composable/mini/57-typescript-streaming-batches-files.md +384 -0
  107. package/assets/skills/converted/claude-api/composable/mini/58-typescript-managed-agents.md +358 -0
  108. package/assets/skills/converted/claude-api/composable/mini/60-csharp-readme.md +361 -0
  109. package/assets/skills/converted/claude-api/composable/mini/61-csharp-tool-use.md +163 -0
  110. package/assets/skills/converted/claude-api/composable/mini/62-csharp-streaming-batches-files.md +64 -0
  111. package/assets/skills/converted/claude-api/composable/mini/65-go-readme.md +185 -0
  112. package/assets/skills/converted/claude-api/composable/mini/66-go-tool-use.md +219 -0
  113. package/assets/skills/converted/claude-api/composable/mini/67-go-streaming-files.md +63 -0
  114. package/assets/skills/converted/claude-api/composable/mini/68-go-managed-agents.md +564 -0
  115. package/assets/skills/converted/claude-api/composable/mini/70-java-readme.md +237 -0
  116. package/assets/skills/converted/claude-api/composable/mini/71-java-tool-use.md +227 -0
  117. package/assets/skills/converted/claude-api/composable/mini/72-java-streaming-files.md +49 -0
  118. package/assets/skills/converted/claude-api/composable/mini/73-java-managed-agents.md +443 -0
  119. package/assets/skills/converted/claude-api/composable/mini/75-php-readme.md +173 -0
  120. package/assets/skills/converted/claude-api/composable/mini/76-php-tool-use.md +252 -0
  121. package/assets/skills/converted/claude-api/composable/mini/77-php-streaming-batches-files.md +53 -0
  122. package/assets/skills/converted/claude-api/composable/mini/78-php-managed-agents.md +443 -0
  123. package/assets/skills/converted/claude-api/composable/mini/80-ruby-readme.md +133 -0
  124. package/assets/skills/converted/claude-api/composable/mini/81-ruby-tool-use-streaming.md +56 -0
  125. package/assets/skills/converted/claude-api/composable/mini/82-ruby-managed-agents.md +394 -0
  126. package/assets/skills/converted/claude-api/composable/mini/85-curl-examples.md +255 -0
  127. package/assets/skills/converted/claude-api/composable/mini/86-curl-managed-agents.md +340 -0
  128. package/assets/skills/converted/claude-api/composable/presets/csharp.md +1151 -0
  129. package/assets/skills/converted/claude-api/composable/presets/curl.md +1154 -0
  130. package/assets/skills/converted/claude-api/composable/presets/go.md +1598 -0
  131. package/assets/skills/converted/claude-api/composable/presets/java.md +1523 -0
  132. package/assets/skills/converted/claude-api/composable/presets/php.md +1488 -0
  133. package/assets/skills/converted/claude-api/composable/presets/python.md +2605 -0
  134. package/assets/skills/converted/claude-api/composable/presets/ruby.md +1146 -0
  135. package/assets/skills/converted/claude-api/composable/presets/shared.md +6478 -0
  136. package/assets/skills/converted/claude-api/composable/presets/typescript.md +2261 -0
  137. package/assets/skills/converted/docx/composable/BUNDLE.md +617 -0
  138. package/assets/skills/converted/docx/composable/INDEX.md +12 -0
  139. package/assets/skills/converted/docx/composable/VERSION +1 -0
  140. package/assets/skills/converted/docx/composable/mini/00-core.md +26 -0
  141. package/assets/skills/converted/docx/composable/mini/01-reading-converting.md +36 -0
  142. package/assets/skills/converted/docx/composable/mini/02-creating-setup-layout.md +85 -0
  143. package/assets/skills/converted/docx/composable/mini/03-creating-elements.md +257 -0
  144. package/assets/skills/converted/docx/composable/mini/04-editing-existing.md +57 -0
  145. package/assets/skills/converted/docx/composable/mini/05-xml-reference.md +128 -0
  146. package/assets/skills/converted/internal-comms/composable/BUNDLE.md +220 -0
  147. package/assets/skills/converted/internal-comms/composable/INDEX.md +11 -0
  148. package/assets/skills/converted/internal-comms/composable/VERSION +1 -0
  149. package/assets/skills/converted/internal-comms/composable/mini/00-core.md +30 -0
  150. package/assets/skills/converted/internal-comms/composable/mini/01-3p-updates.md +49 -0
  151. package/assets/skills/converted/internal-comms/composable/mini/02-company-newsletter.md +67 -0
  152. package/assets/skills/converted/internal-comms/composable/mini/03-faq-answers.md +32 -0
  153. package/assets/skills/converted/internal-comms/composable/mini/04-general-comms.md +18 -0
  154. package/assets/skills/converted/mcp-builder/composable/BUNDLE.md +2460 -0
  155. package/assets/skills/converted/mcp-builder/composable/INDEX.md +23 -0
  156. package/assets/skills/converted/mcp-builder/composable/VERSION +1 -0
  157. package/assets/skills/converted/mcp-builder/composable/mini/00-core.md +43 -0
  158. package/assets/skills/converted/mcp-builder/composable/mini/01-workflow-research-planning.md +54 -0
  159. package/assets/skills/converted/mcp-builder/composable/mini/02-implementation-process.md +78 -0
  160. package/assets/skills/converted/mcp-builder/composable/mini/03-naming-conventions.md +33 -0
  161. package/assets/skills/converted/mcp-builder/composable/mini/04-response-formats.md +21 -0
  162. package/assets/skills/converted/mcp-builder/composable/mini/05-pagination.md +24 -0
  163. package/assets/skills/converted/mcp-builder/composable/mini/06-transport.md +47 -0
  164. package/assets/skills/converted/mcp-builder/composable/mini/07-annotations.md +20 -0
  165. package/assets/skills/converted/mcp-builder/composable/mini/08-security.md +35 -0
  166. package/assets/skills/converted/mcp-builder/composable/mini/09-error-handling.md +32 -0
  167. package/assets/skills/converted/mcp-builder/composable/mini/10-testing-and-documentation.md +21 -0
  168. package/assets/skills/converted/mcp-builder/composable/mini/11-python-implementation.md +432 -0
  169. package/assets/skills/converted/mcp-builder/composable/mini/12-python-advanced-and-checklist.md +233 -0
  170. package/assets/skills/converted/mcp-builder/composable/mini/13-node-implementation.md +717 -0
  171. package/assets/skills/converted/mcp-builder/composable/mini/14-node-advanced-and-checklist.md +200 -0
  172. package/assets/skills/converted/mcp-builder/composable/mini/15-evaluation-design.md +200 -0
  173. package/assets/skills/converted/mcp-builder/composable/mini/16-evaluation-running.md +198 -0
  174. package/assets/skills/converted/mcp-builder/composable/presets/node-server.md +1381 -0
  175. package/assets/skills/converted/mcp-builder/composable/presets/python-server.md +1129 -0
  176. package/assets/skills/converted/pdf/composable/BUNDLE.md +1284 -0
  177. package/assets/skills/converted/pdf/composable/INDEX.md +14 -0
  178. package/assets/skills/converted/pdf/composable/VERSION +1 -0
  179. package/assets/skills/converted/pdf/composable/mini/00-core.md +46 -0
  180. package/assets/skills/converted/pdf/composable/mini/01-creation.md +176 -0
  181. package/assets/skills/converted/pdf/composable/mini/02-extraction.md +178 -0
  182. package/assets/skills/converted/pdf/composable/mini/03-merge-split-manipulate.md +240 -0
  183. package/assets/skills/converted/pdf/composable/mini/04-images-ocr.md +168 -0
  184. package/assets/skills/converted/pdf/composable/mini/05-encryption.md +51 -0
  185. package/assets/skills/converted/pdf/composable/mini/06-forms.md +300 -0
  186. package/assets/skills/converted/pdf/composable/mini/07-libraries-reference.md +89 -0
  187. package/assets/skills/converted/pptx/composable/BUNDLE.md +911 -0
  188. package/assets/skills/converted/pptx/composable/INDEX.md +12 -0
  189. package/assets/skills/converted/pptx/composable/VERSION +1 -0
  190. package/assets/skills/converted/pptx/composable/mini/00-core.md +37 -0
  191. package/assets/skills/converted/pptx/composable/mini/01-reading.md +37 -0
  192. package/assets/skills/converted/pptx/composable/mini/02-creating-from-scratch.md +422 -0
  193. package/assets/skills/converted/pptx/composable/mini/03-editing-templates.md +207 -0
  194. package/assets/skills/converted/pptx/composable/mini/04-design.md +89 -0
  195. package/assets/skills/converted/pptx/composable/mini/05-qa-and-rendering.md +91 -0
  196. package/assets/skills/converted/pptx/composable/presets/creating.md +659 -0
  197. package/assets/skills/converted/pptx/composable/presets/editing.md +485 -0
  198. package/assets/skills/converted/skill-creator/composable/BUNDLE.md +1681 -0
  199. package/assets/skills/converted/skill-creator/composable/INDEX.md +21 -0
  200. package/assets/skills/converted/skill-creator/composable/VERSION +1 -0
  201. package/assets/skills/converted/skill-creator/composable/mini/00-core.md +59 -0
  202. package/assets/skills/converted/skill-creator/composable/mini/01-creating-a-skill.md +27 -0
  203. package/assets/skills/converted/skill-creator/composable/mini/02-skill-writing-guide.md +71 -0
  204. package/assets/skills/converted/skill-creator/composable/mini/03-test-cases.md +21 -0
  205. package/assets/skills/converted/skill-creator/composable/mini/04-running-and-evaluating.md +128 -0
  206. package/assets/skills/converted/skill-creator/composable/mini/05-improving-the-skill.md +30 -0
  207. package/assets/skills/converted/skill-creator/composable/mini/06-blind-comparison.md +5 -0
  208. package/assets/skills/converted/skill-creator/composable/mini/07-description-optimization.md +74 -0
  209. package/assets/skills/converted/skill-creator/composable/mini/08-packaging.md +11 -0
  210. package/assets/skills/converted/skill-creator/composable/mini/09-environment-specific.md +38 -0
  211. package/assets/skills/converted/skill-creator/composable/mini/10-scripts-and-references.md +34 -0
  212. package/assets/skills/converted/skill-creator/composable/mini/11-json-schemas.md +414 -0
  213. package/assets/skills/converted/skill-creator/composable/mini/12-agent-grader.md +225 -0
  214. package/assets/skills/converted/skill-creator/composable/mini/13-agent-comparator.md +204 -0
  215. package/assets/skills/converted/skill-creator/composable/mini/14-agent-analyzer.md +276 -0
  216. package/assets/skills/converted/skill-creator/composable/presets/authoring.md +198 -0
  217. package/assets/skills/converted/skill-creator/composable/presets/evaluating.md +1334 -0
  218. package/assets/skills/converted/skill-creator/composable/presets/optimizing.md +160 -0
  219. package/assets/skills/converted/skill-creator/composable/presets.json +5 -0
  220. package/assets/skills/meta/ccs-skill-creator/composable/BUNDLE.md +465 -0
  221. package/assets/skills/meta/ccs-skill-creator/composable/INDEX.md +8 -0
  222. package/assets/skills/meta/ccs-skill-creator/composable/VERSION +1 -0
  223. package/assets/skills/meta/ccs-skill-creator/composable/mini/00-core.md +46 -0
  224. package/assets/skills/meta/ccs-skill-creator/composable/mini/01-create-new-skill.md +167 -0
  225. package/assets/skills/meta/ccs-skill-creator/composable/mini/02-convert-existing-skill.md +120 -0
  226. package/assets/skills/meta/ccs-skill-creator/composable/mini/03-review-and-maintain.md +112 -0
  227. package/assets/skills/sources/anthropic/PROVENANCE.md +3 -0
  228. package/assets/skills/sources/anthropic/claude-api/LICENSE.txt +202 -0
  229. package/assets/skills/sources/anthropic/docx/LICENSE.txt +30 -0
  230. package/assets/skills/sources/anthropic/internal-comms/LICENSE.txt +202 -0
  231. package/assets/skills/sources/anthropic/mcp-builder/LICENSE.txt +202 -0
  232. package/assets/skills/sources/anthropic/pdf/LICENSE.txt +30 -0
  233. package/assets/skills/sources/anthropic/pptx/LICENSE.txt +30 -0
  234. package/assets/skills/sources/anthropic/skill-creator/LICENSE.txt +202 -0
  235. package/assets/skills/sources/financial-analyst/PROVENANCE.md +1 -0
  236. package/assets/tools/hive.py +728 -0
  237. package/dist/cli.js +7494 -0
  238. package/package.json +40 -0
@@ -0,0 +1,168 @@
1
+ # Images, Rendering, and OCR
2
+
3
+ Extracting images, rendering pages to images, extracting figures, and OCR on scanned PDFs (pdfimages, pypdfium2, pdftoppm, pdfjs-dist, pytesseract).
4
+
5
+ ## Extract Text from Scanned PDFs (OCR)
6
+ ```python
7
+ # Requires: pip install pytesseract pdf2image
8
+ import pytesseract
9
+ from pdf2image import convert_from_path
10
+
11
+ # Convert PDF to images
12
+ images = convert_from_path('scanned.pdf')
13
+
14
+ # OCR each page
15
+ text = ""
16
+ for i, image in enumerate(images):
17
+ text += f"Page {i+1}:\n"
18
+ text += pytesseract.image_to_string(image)
19
+ text += "\n\n"
20
+
21
+ print(text)
22
+ ```
23
+
24
+ ## Extract Images
25
+ ```bash
26
+ # Using pdfimages (poppler-utils)
27
+ pdfimages -j input.pdf output_prefix
28
+
29
+ # This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.
30
+ ```
31
+
32
+ ## pypdfium2 Library (Apache/BSD License)
33
+
34
+ ### Overview
35
+ pypdfium2 is a Python binding for PDFium (Chromium's PDF library). It's excellent for fast PDF rendering, image generation, and serves as a PyMuPDF replacement.
36
+
37
+ ### Render PDF to Images
38
+ ```python
39
+ import pypdfium2 as pdfium
40
+ from PIL import Image
41
+
42
+ # Load PDF
43
+ pdf = pdfium.PdfDocument("document.pdf")
44
+
45
+ # Render page to image
46
+ page = pdf[0] # First page
47
+ bitmap = page.render(
48
+ scale=2.0, # Higher resolution
49
+ rotation=0 # No rotation
50
+ )
51
+
52
+ # Convert to PIL Image
53
+ img = bitmap.to_pil()
54
+ img.save("page_1.png", "PNG")
55
+
56
+ # Process multiple pages
57
+ for i, page in enumerate(pdf):
58
+ bitmap = page.render(scale=1.5)
59
+ img = bitmap.to_pil()
60
+ img.save(f"page_{i+1}.jpg", "JPEG", quality=90)
61
+ ```
62
+
63
+ ### Extract Text with pypdfium2
64
+ ```python
65
+ import pypdfium2 as pdfium
66
+
67
+ pdf = pdfium.PdfDocument("document.pdf")
68
+ for i, page in enumerate(pdf):
69
+ text = page.get_text()
70
+ print(f"Page {i+1} text length: {len(text)} chars")
71
+ ```
72
+
73
+ ## pdfjs-dist (Apache License) - Rendering
74
+
75
+ PDF.js is Mozilla's JavaScript library for rendering PDFs in the browser.
76
+
77
+ ### Basic PDF Loading and Rendering
78
+ ```javascript
79
+ import * as pdfjsLib from 'pdfjs-dist';
80
+
81
+ // Configure worker (important for performance)
82
+ pdfjsLib.GlobalWorkerOptions.workerSrc = './pdf.worker.js';
83
+
84
+ async function renderPDF() {
85
+ // Load PDF
86
+ const loadingTask = pdfjsLib.getDocument('document.pdf');
87
+ const pdf = await loadingTask.promise;
88
+
89
+ console.log(`Loaded PDF with ${pdf.numPages} pages`);
90
+
91
+ // Get first page
92
+ const page = await pdf.getPage(1);
93
+ const viewport = page.getViewport({ scale: 1.5 });
94
+
95
+ // Render to canvas
96
+ const canvas = document.createElement('canvas');
97
+ const context = canvas.getContext('2d');
98
+ canvas.height = viewport.height;
99
+ canvas.width = viewport.width;
100
+
101
+ const renderContext = {
102
+ canvasContext: context,
103
+ viewport: viewport
104
+ };
105
+
106
+ await page.render(renderContext).promise;
107
+ document.body.appendChild(canvas);
108
+ }
109
+ ```
110
+
111
+ ## Advanced Image Conversion (poppler-utils)
112
+ ```bash
113
+ # Convert to PNG images with specific resolution
114
+ pdftoppm -png -r 300 document.pdf output_prefix
115
+
116
+ # Convert specific page range with high resolution
117
+ pdftoppm -png -r 600 -f 1 -l 3 document.pdf high_res_pages
118
+
119
+ # Convert to JPEG with quality setting
120
+ pdftoppm -jpeg -jpegopt quality=85 -r 200 document.pdf jpeg_output
121
+ ```
122
+
123
+ ## Extract Embedded Images (poppler-utils)
124
+ ```bash
125
+ # Extract all embedded images with metadata
126
+ pdfimages -j -p document.pdf page_images
127
+
128
+ # List image info without extracting
129
+ pdfimages -list document.pdf
130
+
131
+ # Extract images in their original format
132
+ pdfimages -all document.pdf images/img
133
+ ```
134
+
135
+ ## Extract Figures/Images from PDF
136
+
137
+ ### Method 1: Using pdfimages (fastest)
138
+ ```bash
139
+ # Extract all images with original quality
140
+ pdfimages -all document.pdf images/img
141
+ ```
142
+
143
+ ### Method 2: Using pypdfium2 + Image Processing
144
+ ```python
145
+ import pypdfium2 as pdfium
146
+ from PIL import Image
147
+ import numpy as np
148
+
149
+ def extract_figures(pdf_path, output_dir):
150
+ pdf = pdfium.PdfDocument(pdf_path)
151
+
152
+ for page_num, page in enumerate(pdf):
153
+ # Render high-resolution page
154
+ bitmap = page.render(scale=3.0)
155
+ img = bitmap.to_pil()
156
+
157
+ # Convert to numpy for processing
158
+ img_array = np.array(img)
159
+
160
+ # Simple figure detection (non-white regions)
161
+ mask = np.any(img_array != [255, 255, 255], axis=2)
162
+
163
+ # Find contours and extract bounding boxes
164
+ # (This is simplified - real implementation would need more sophisticated detection)
165
+
166
+ # Save detected figures
167
+ # ... implementation depends on specific needs
168
+ ```
@@ -0,0 +1,51 @@
1
+ # Encryption, Passwords, and Decryption
2
+
3
+ Adding and removing password protection and setting permissions (pypdf, qpdf).
4
+
5
+ ## Password Protection (pypdf)
6
+ ```python
7
+ from pypdf import PdfReader, PdfWriter
8
+
9
+ reader = PdfReader("input.pdf")
10
+ writer = PdfWriter()
11
+
12
+ for page in reader.pages:
13
+ writer.add_page(page)
14
+
15
+ # Add password
16
+ writer.encrypt("userpassword", "ownerpassword")
17
+
18
+ with open("encrypted.pdf", "wb") as output:
19
+ writer.write(output)
20
+ ```
21
+
22
+ ## Remove Password (qpdf)
23
+ ```bash
24
+ # Remove password
25
+ qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf
26
+ ```
27
+
28
+ ## Advanced Encryption (qpdf)
29
+ ```bash
30
+ # Add password protection with specific permissions
31
+ qpdf --encrypt user_pass owner_pass 256 --print=none --modify=none -- input.pdf encrypted.pdf
32
+
33
+ # Check encryption status
34
+ qpdf --show-encryption encrypted.pdf
35
+
36
+ # Remove password protection (requires password)
37
+ qpdf --password=secret123 --decrypt encrypted.pdf decrypted.pdf
38
+ ```
39
+
40
+ ## Handling Encrypted PDFs (pypdf)
41
+ ```python
42
+ # Handle password-protected PDFs
43
+ from pypdf import PdfReader
44
+
45
+ try:
46
+ reader = PdfReader("encrypted.pdf")
47
+ if reader.is_encrypted:
48
+ reader.decrypt("password")
49
+ except Exception as e:
50
+ print(f"Failed to decrypt: {e}")
51
+ ```
@@ -0,0 +1,300 @@
1
+ # Filling PDF Forms
2
+
3
+ Filling both fillable (AcroForm) and non-fillable (flat/scanned) PDF forms.
4
+
5
+ > **Vendored scripts:** every `python scripts/...` command below refers to the helper scripts vendored in the source skill at `skills/sources/anthropic/pdf/scripts/` (`check_fillable_fields.py`, `extract_form_field_info.py`, `convert_pdf_to_images.py`, `fill_fillable_fields.py`, `extract_form_structure.py`, `check_bounding_boxes.py`, `fill_pdf_form_with_annotations.py`). "This file's directory" means the source skill directory.
6
+
7
+ **CRITICAL: You MUST complete these steps in order. Do not skip ahead to writing code.**
8
+
9
+ If you need to fill out a PDF form, first check to see if the PDF has fillable form fields. Run this script from this file's directory:
10
+ `python scripts/check_fillable_fields <file.pdf>`, and depending on the result go to either the "Fillable fields" or "Non-fillable fields" and follow those instructions.
11
+
12
+ # Fillable fields
13
+ If the PDF has fillable form fields:
14
+ - Run this script from this file's directory: `python scripts/extract_form_field_info.py <input.pdf> <field_info.json>`. It will create a JSON file with a list of fields in this format:
15
+ ```
16
+ [
17
+ {
18
+ "field_id": (unique ID for the field),
19
+ "page": (page number, 1-based),
20
+ "rect": ([left, bottom, right, top] bounding box in PDF coordinates, y=0 is the bottom of the page),
21
+ "type": ("text", "checkbox", "radio_group", or "choice"),
22
+ },
23
+ // Checkboxes have "checked_value" and "unchecked_value" properties:
24
+ {
25
+ "field_id": (unique ID for the field),
26
+ "page": (page number, 1-based),
27
+ "type": "checkbox",
28
+ "checked_value": (Set the field to this value to check the checkbox),
29
+ "unchecked_value": (Set the field to this value to uncheck the checkbox),
30
+ },
31
+ // Radio groups have a "radio_options" list with the possible choices.
32
+ {
33
+ "field_id": (unique ID for the field),
34
+ "page": (page number, 1-based),
35
+ "type": "radio_group",
36
+ "radio_options": [
37
+ {
38
+ "value": (set the field to this value to select this radio option),
39
+ "rect": (bounding box for the radio button for this option)
40
+ },
41
+ // Other radio options
42
+ ]
43
+ },
44
+ // Multiple choice fields have a "choice_options" list with the possible choices:
45
+ {
46
+ "field_id": (unique ID for the field),
47
+ "page": (page number, 1-based),
48
+ "type": "choice",
49
+ "choice_options": [
50
+ {
51
+ "value": (set the field to this value to select this option),
52
+ "text": (display text of the option)
53
+ },
54
+ // Other choice options
55
+ ],
56
+ }
57
+ ]
58
+ ```
59
+ - Convert the PDF to PNGs (one image for each page) with this script (run from this file's directory):
60
+ `python scripts/convert_pdf_to_images.py <file.pdf> <output_directory>`
61
+ Then analyze the images to determine the purpose of each form field (make sure to convert the bounding box PDF coordinates to image coordinates).
62
+ - Create a `field_values.json` file in this format with the values to be entered for each field:
63
+ ```
64
+ [
65
+ {
66
+ "field_id": "last_name", // Must match the field_id from `extract_form_field_info.py`
67
+ "description": "The user's last name",
68
+ "page": 1, // Must match the "page" value in field_info.json
69
+ "value": "Simpson"
70
+ },
71
+ {
72
+ "field_id": "Checkbox12",
73
+ "description": "Checkbox to be checked if the user is 18 or over",
74
+ "page": 1,
75
+ "value": "/On" // If this is a checkbox, use its "checked_value" value to check it. If it's a radio button group, use one of the "value" values in "radio_options".
76
+ },
77
+ // more fields
78
+ ]
79
+ ```
80
+ - Run the `fill_fillable_fields.py` script from this file's directory to create a filled-in PDF:
81
+ `python scripts/fill_fillable_fields.py <input pdf> <field_values.json> <output pdf>`
82
+ This script will verify that the field IDs and values you provide are valid; if it prints error messages, correct the appropriate fields and try again.
83
+
84
+ # Non-fillable fields
85
+ If the PDF doesn't have fillable form fields, you'll add text annotations. First try to extract coordinates from the PDF structure (more accurate), then fall back to visual estimation if needed.
86
+
87
+ ## Step 1: Try Structure Extraction First
88
+
89
+ Run this script to extract text labels, lines, and checkboxes with their exact PDF coordinates:
90
+ `python scripts/extract_form_structure.py <input.pdf> form_structure.json`
91
+
92
+ This creates a JSON file containing:
93
+ - **labels**: Every text element with exact coordinates (x0, top, x1, bottom in PDF points)
94
+ - **lines**: Horizontal lines that define row boundaries
95
+ - **checkboxes**: Small square rectangles that are checkboxes (with center coordinates)
96
+ - **row_boundaries**: Row top/bottom positions calculated from horizontal lines
97
+
98
+ **Check the results**: If `form_structure.json` has meaningful labels (text elements that correspond to form fields), use **Approach A: Structure-Based Coordinates**. If the PDF is scanned/image-based and has few or no labels, use **Approach B: Visual Estimation**.
99
+
100
+ ---
101
+
102
+ ## Approach A: Structure-Based Coordinates (Preferred)
103
+
104
+ Use this when `extract_form_structure.py` found text labels in the PDF.
105
+
106
+ ### A.1: Analyze the Structure
107
+
108
+ Read form_structure.json and identify:
109
+
110
+ 1. **Label groups**: Adjacent text elements that form a single label (e.g., "Last" + "Name")
111
+ 2. **Row structure**: Labels with similar `top` values are in the same row
112
+ 3. **Field columns**: Entry areas start after label ends (x0 = label.x1 + gap)
113
+ 4. **Checkboxes**: Use the checkbox coordinates directly from the structure
114
+
115
+ **Coordinate system**: PDF coordinates where y=0 is at TOP of page, y increases downward.
116
+
117
+ ### A.2: Check for Missing Elements
118
+
119
+ The structure extraction may not detect all form elements. Common cases:
120
+ - **Circular checkboxes**: Only square rectangles are detected as checkboxes
121
+ - **Complex graphics**: Decorative elements or non-standard form controls
122
+ - **Faded or light-colored elements**: May not be extracted
123
+
124
+ If you see form fields in the PDF images that aren't in form_structure.json, you'll need to use **visual analysis** for those specific fields (see "Hybrid Approach" below).
125
+
126
+ ### A.3: Create fields.json with PDF Coordinates
127
+
128
+ For each field, calculate entry coordinates from the extracted structure:
129
+
130
+ **Text fields:**
131
+ - entry x0 = label x1 + 5 (small gap after label)
132
+ - entry x1 = next label's x0, or row boundary
133
+ - entry top = same as label top
134
+ - entry bottom = row boundary line below, or label bottom + row_height
135
+
136
+ **Checkboxes:**
137
+ - Use the checkbox rectangle coordinates directly from form_structure.json
138
+ - entry_bounding_box = [checkbox.x0, checkbox.top, checkbox.x1, checkbox.bottom]
139
+
140
+ Create fields.json using `pdf_width` and `pdf_height` (signals PDF coordinates):
141
+ ```json
142
+ {
143
+ "pages": [
144
+ {"page_number": 1, "pdf_width": 612, "pdf_height": 792}
145
+ ],
146
+ "form_fields": [
147
+ {
148
+ "page_number": 1,
149
+ "description": "Last name entry field",
150
+ "field_label": "Last Name",
151
+ "label_bounding_box": [43, 63, 87, 73],
152
+ "entry_bounding_box": [92, 63, 260, 79],
153
+ "entry_text": {"text": "Smith", "font_size": 10}
154
+ },
155
+ {
156
+ "page_number": 1,
157
+ "description": "US Citizen Yes checkbox",
158
+ "field_label": "Yes",
159
+ "label_bounding_box": [260, 200, 280, 210],
160
+ "entry_bounding_box": [285, 197, 292, 205],
161
+ "entry_text": {"text": "X"}
162
+ }
163
+ ]
164
+ }
165
+ ```
166
+
167
+ **Important**: Use `pdf_width`/`pdf_height` and coordinates directly from form_structure.json.
168
+
169
+ ### A.4: Validate Bounding Boxes
170
+
171
+ Before filling, check your bounding boxes for errors:
172
+ `python scripts/check_bounding_boxes.py fields.json`
173
+
174
+ This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling.
175
+
176
+ ---
177
+
178
+ ## Approach B: Visual Estimation (Fallback)
179
+
180
+ Use this when the PDF is scanned/image-based and structure extraction found no usable text labels (e.g., all text shows as "(cid:X)" patterns).
181
+
182
+ ### B.1: Convert PDF to Images
183
+
184
+ `python scripts/convert_pdf_to_images.py <input.pdf> <images_dir/>`
185
+
186
+ ### B.2: Initial Field Identification
187
+
188
+ Examine each page image to identify form sections and get **rough estimates** of field locations:
189
+ - Form field labels and their approximate positions
190
+ - Entry areas (lines, boxes, or blank spaces for text input)
191
+ - Checkboxes and their approximate locations
192
+
193
+ For each field, note approximate pixel coordinates (they don't need to be precise yet).
194
+
195
+ ### B.3: Zoom Refinement (CRITICAL for accuracy)
196
+
197
+ For each field, crop a region around the estimated position to refine coordinates precisely.
198
+
199
+ **Create a zoomed crop using ImageMagick:**
200
+ ```bash
201
+ magick <page_image> -crop <width>x<height>+<x>+<y> +repage <crop_output.png>
202
+ ```
203
+
204
+ Where:
205
+ - `<x>, <y>` = top-left corner of crop region (use your rough estimate minus padding)
206
+ - `<width>, <height>` = size of crop region (field area plus ~50px padding on each side)
207
+
208
+ **Example:** To refine a "Name" field estimated around (100, 150):
209
+ ```bash
210
+ magick images_dir/page_1.png -crop 300x80+50+120 +repage crops/name_field.png
211
+ ```
212
+
213
+ (Note: if the `magick` command isn't available, try `convert` with the same arguments).
214
+
215
+ **Examine the cropped image** to determine precise coordinates:
216
+ 1. Identify the exact pixel where the entry area begins (after the label)
217
+ 2. Identify where the entry area ends (before next field or edge)
218
+ 3. Identify the top and bottom of the entry line/box
219
+
220
+ **Convert crop coordinates back to full image coordinates:**
221
+ - full_x = crop_x + crop_offset_x
222
+ - full_y = crop_y + crop_offset_y
223
+
224
+ Example: If the crop started at (50, 120) and the entry box starts at (52, 18) within the crop:
225
+ - entry_x0 = 52 + 50 = 102
226
+ - entry_top = 18 + 120 = 138
227
+
228
+ **Repeat for each field**, grouping nearby fields into single crops when possible.
229
+
230
+ ### B.4: Create fields.json with Refined Coordinates
231
+
232
+ Create fields.json using `image_width` and `image_height` (signals image coordinates):
233
+ ```json
234
+ {
235
+ "pages": [
236
+ {"page_number": 1, "image_width": 1700, "image_height": 2200}
237
+ ],
238
+ "form_fields": [
239
+ {
240
+ "page_number": 1,
241
+ "description": "Last name entry field",
242
+ "field_label": "Last Name",
243
+ "label_bounding_box": [120, 175, 242, 198],
244
+ "entry_bounding_box": [255, 175, 720, 218],
245
+ "entry_text": {"text": "Smith", "font_size": 10}
246
+ }
247
+ ]
248
+ }
249
+ ```
250
+
251
+ **Important**: Use `image_width`/`image_height` and the refined pixel coordinates from the zoom analysis.
252
+
253
+ ### B.5: Validate Bounding Boxes
254
+
255
+ Before filling, check your bounding boxes for errors:
256
+ `python scripts/check_bounding_boxes.py fields.json`
257
+
258
+ This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling.
259
+
260
+ ---
261
+
262
+ ## Hybrid Approach: Structure + Visual
263
+
264
+ Use this when structure extraction works for most fields but misses some elements (e.g., circular checkboxes, unusual form controls).
265
+
266
+ 1. **Use Approach A** for fields that were detected in form_structure.json
267
+ 2. **Convert PDF to images** for visual analysis of missing fields
268
+ 3. **Use zoom refinement** (from Approach B) for the missing fields
269
+ 4. **Combine coordinates**: For fields from structure extraction, use `pdf_width`/`pdf_height`. For visually-estimated fields, you must convert image coordinates to PDF coordinates:
270
+ - pdf_x = image_x * (pdf_width / image_width)
271
+ - pdf_y = image_y * (pdf_height / image_height)
272
+ 5. **Use a single coordinate system** in fields.json - convert all to PDF coordinates with `pdf_width`/`pdf_height`
273
+
274
+ ---
275
+
276
+ ## Step 2: Validate Before Filling
277
+
278
+ **Always validate bounding boxes before filling:**
279
+ `python scripts/check_bounding_boxes.py fields.json`
280
+
281
+ This checks for:
282
+ - Intersecting bounding boxes (which would cause overlapping text)
283
+ - Entry boxes that are too small for the specified font size
284
+
285
+ Fix any reported errors in fields.json before proceeding.
286
+
287
+ ## Step 3: Fill the Form
288
+
289
+ The fill script auto-detects the coordinate system and handles conversion:
290
+ `python scripts/fill_pdf_form_with_annotations.py <input.pdf> fields.json <output.pdf>`
291
+
292
+ ## Step 4: Verify Output
293
+
294
+ Convert the filled PDF to images and verify text placement:
295
+ `python scripts/convert_pdf_to_images.py <output.pdf> <verify_images/>`
296
+
297
+ If text is mispositioned:
298
+ - **Approach A**: Check that you're using PDF coordinates from form_structure.json with `pdf_width`/`pdf_height`
299
+ - **Approach B**: Check that image dimensions match and coordinates are accurate pixels
300
+ - **Hybrid**: Ensure coordinate conversions are correct for visually-estimated fields
@@ -0,0 +1,89 @@
1
+ # Library Guidance, Performance, Troubleshooting, and Licenses
2
+
3
+ Cross-cutting reference: performance optimization, troubleshooting recipes, and per-library license information. For library-specific code, see the creation, extraction, merge-split, and images-ocr minis.
4
+
5
+ ## Performance Optimization Tips
6
+
7
+ ### 1. For Large PDFs
8
+ - Use streaming approaches instead of loading entire PDF in memory
9
+ - Use `qpdf --split-pages` for splitting large files
10
+ - Process pages individually with pypdfium2
11
+
12
+ ### 2. For Text Extraction
13
+ - `pdftotext -bbox-layout` is fastest for plain text extraction
14
+ - Use pdfplumber for structured data and tables
15
+ - Avoid `pypdf.extract_text()` for very large documents
16
+
17
+ ### 3. For Image Extraction
18
+ - `pdfimages` is much faster than rendering pages
19
+ - Use low resolution for previews, high resolution for final output
20
+
21
+ ### 4. For Form Filling
22
+ - pdf-lib maintains form structure better than most alternatives
23
+ - Pre-validate form fields before processing
24
+
25
+ ### 5. Memory Management
26
+ ```python
27
+ # Process PDFs in chunks
28
+ def process_large_pdf(pdf_path, chunk_size=10):
29
+ reader = PdfReader(pdf_path)
30
+ total_pages = len(reader.pages)
31
+
32
+ for start_idx in range(0, total_pages, chunk_size):
33
+ end_idx = min(start_idx + chunk_size, total_pages)
34
+ writer = PdfWriter()
35
+
36
+ for i in range(start_idx, end_idx):
37
+ writer.add_page(reader.pages[i])
38
+
39
+ # Process chunk
40
+ with open(f"chunk_{start_idx//chunk_size}.pdf", "wb") as output:
41
+ writer.write(output)
42
+ ```
43
+
44
+ ## Troubleshooting Common Issues
45
+
46
+ ### Encrypted PDFs
47
+ ```python
48
+ # Handle password-protected PDFs
49
+ from pypdf import PdfReader
50
+
51
+ try:
52
+ reader = PdfReader("encrypted.pdf")
53
+ if reader.is_encrypted:
54
+ reader.decrypt("password")
55
+ except Exception as e:
56
+ print(f"Failed to decrypt: {e}")
57
+ ```
58
+
59
+ ### Corrupted PDFs
60
+ ```bash
61
+ # Use qpdf to repair
62
+ qpdf --check corrupted.pdf
63
+ qpdf --replace-input corrupted.pdf
64
+ ```
65
+
66
+ ### Text Extraction Issues
67
+ ```python
68
+ # Fallback to OCR for scanned PDFs
69
+ import pytesseract
70
+ from pdf2image import convert_from_path
71
+
72
+ def extract_text_with_ocr(pdf_path):
73
+ images = convert_from_path(pdf_path)
74
+ text = ""
75
+ for i, image in enumerate(images):
76
+ text += pytesseract.image_to_string(image)
77
+ return text
78
+ ```
79
+
80
+ ## License Information
81
+
82
+ - **pypdf**: BSD License
83
+ - **pdfplumber**: MIT License
84
+ - **pypdfium2**: Apache/BSD License
85
+ - **reportlab**: BSD License
86
+ - **poppler-utils**: GPL-2 License
87
+ - **qpdf**: Apache License
88
+ - **pdf-lib**: MIT License
89
+ - **pdfjs-dist**: Apache License