format: apply repo prettier (3.8.1) to the folded skills tree
963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
This commit is contained in:
@@ -30,6 +30,7 @@ for page in reader.pages:
|
||||
### pypdf - Basic Operations
|
||||
|
||||
#### Merge PDFs
|
||||
|
||||
```python
|
||||
from pypdf import PdfWriter, PdfReader
|
||||
|
||||
@@ -44,6 +45,7 @@ with open("merged.pdf", "wb") as output:
|
||||
```
|
||||
|
||||
#### Split PDF
|
||||
|
||||
```python
|
||||
reader = PdfReader("input.pdf")
|
||||
for i, page in enumerate(reader.pages):
|
||||
@@ -54,6 +56,7 @@ for i, page in enumerate(reader.pages):
|
||||
```
|
||||
|
||||
#### Extract Metadata
|
||||
|
||||
```python
|
||||
reader = PdfReader("document.pdf")
|
||||
meta = reader.metadata
|
||||
@@ -64,6 +67,7 @@ print(f"Creator: {meta.creator}")
|
||||
```
|
||||
|
||||
#### Rotate Pages
|
||||
|
||||
```python
|
||||
reader = PdfReader("input.pdf")
|
||||
writer = PdfWriter()
|
||||
@@ -79,6 +83,7 @@ with open("rotated.pdf", "wb") as output:
|
||||
### pdfplumber - Text and Table Extraction
|
||||
|
||||
#### Extract Text with Layout
|
||||
|
||||
```python
|
||||
import pdfplumber
|
||||
|
||||
@@ -89,6 +94,7 @@ with pdfplumber.open("document.pdf") as pdf:
|
||||
```
|
||||
|
||||
#### Extract Tables
|
||||
|
||||
```python
|
||||
with pdfplumber.open("document.pdf") as pdf:
|
||||
for i, page in enumerate(pdf.pages):
|
||||
@@ -100,6 +106,7 @@ with pdfplumber.open("document.pdf") as pdf:
|
||||
```
|
||||
|
||||
#### Advanced Table Extraction
|
||||
|
||||
```python
|
||||
import pandas as pd
|
||||
|
||||
@@ -121,6 +128,7 @@ if all_tables:
|
||||
### reportlab - Create PDFs
|
||||
|
||||
#### Basic PDF Creation
|
||||
|
||||
```python
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.pdfgen import canvas
|
||||
@@ -140,6 +148,7 @@ c.save()
|
||||
```
|
||||
|
||||
#### Create PDF with Multiple Pages
|
||||
|
||||
```python
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
|
||||
@@ -171,6 +180,7 @@ doc.build(story)
|
||||
**IMPORTANT**: Never use Unicode subscript/superscript characters (₀₁₂₃₄₅₆₇₈₉, ⁰¹²³⁴⁵⁶⁷⁸⁹) in ReportLab PDFs. The built-in fonts do not include these glyphs, causing them to render as solid black boxes.
|
||||
|
||||
Instead, use ReportLab's XML markup tags in Paragraph objects:
|
||||
|
||||
```python
|
||||
from reportlab.platypus import Paragraph
|
||||
from reportlab.lib.styles import getSampleStyleSheet
|
||||
@@ -189,6 +199,7 @@ For canvas-drawn text (not Paragraph objects), manually adjust font the size and
|
||||
## Command-Line Tools
|
||||
|
||||
### pdftotext (poppler-utils)
|
||||
|
||||
```bash
|
||||
# Extract text
|
||||
pdftotext input.pdf output.txt
|
||||
@@ -201,6 +212,7 @@ pdftotext -f 1 -l 5 input.pdf output.txt # Pages 1-5
|
||||
```
|
||||
|
||||
### qpdf
|
||||
|
||||
```bash
|
||||
# Merge PDFs
|
||||
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf
|
||||
@@ -217,6 +229,7 @@ qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf
|
||||
```
|
||||
|
||||
### pdftk (if available)
|
||||
|
||||
```bash
|
||||
# Merge
|
||||
pdftk file1.pdf file2.pdf cat output merged.pdf
|
||||
@@ -231,6 +244,7 @@ pdftk input.pdf rotate 1east output rotated.pdf
|
||||
## Common Tasks
|
||||
|
||||
### Extract Text from Scanned PDFs
|
||||
|
||||
```python
|
||||
# Requires: pip install pytesseract pdf2image
|
||||
import pytesseract
|
||||
@@ -250,6 +264,7 @@ print(text)
|
||||
```
|
||||
|
||||
### Add Watermark
|
||||
|
||||
```python
|
||||
from pypdf import PdfReader, PdfWriter
|
||||
|
||||
@@ -269,6 +284,7 @@ with open("watermarked.pdf", "wb") as output:
|
||||
```
|
||||
|
||||
### Extract Images
|
||||
|
||||
```bash
|
||||
# Using pdfimages (poppler-utils)
|
||||
pdfimages -j input.pdf output_prefix
|
||||
@@ -277,6 +293,7 @@ pdfimages -j input.pdf output_prefix
|
||||
```
|
||||
|
||||
### Password Protection
|
||||
|
||||
```python
|
||||
from pypdf import PdfReader, PdfWriter
|
||||
|
||||
@@ -295,16 +312,16 @@ with open("encrypted.pdf", "wb") as output:
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Task | Best Tool | Command/Code |
|
||||
|------|-----------|--------------|
|
||||
| Merge PDFs | pypdf | `writer.add_page(page)` |
|
||||
| Split PDFs | pypdf | One page per file |
|
||||
| Extract text | pdfplumber | `page.extract_text()` |
|
||||
| Extract tables | pdfplumber | `page.extract_tables()` |
|
||||
| Create PDFs | reportlab | Canvas or Platypus |
|
||||
| Command line merge | qpdf | `qpdf --empty --pages ...` |
|
||||
| OCR scanned PDFs | pytesseract | Convert to image first |
|
||||
| Fill PDF forms | pdf-lib or pypdf (see FORMS.md) | See FORMS.md |
|
||||
| Task | Best Tool | Command/Code |
|
||||
| ------------------ | ------------------------------- | -------------------------- |
|
||||
| Merge PDFs | pypdf | `writer.add_page(page)` |
|
||||
| Split PDFs | pypdf | One page per file |
|
||||
| Extract text | pdfplumber | `page.extract_text()` |
|
||||
| Extract tables | pdfplumber | `page.extract_tables()` |
|
||||
| Create PDFs | reportlab | Canvas or Platypus |
|
||||
| Command line merge | qpdf | `qpdf --empty --pages ...` |
|
||||
| OCR scanned PDFs | pytesseract | Convert to image first |
|
||||
| Fill PDF forms | pdf-lib or pypdf (see FORMS.md) | See FORMS.md |
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user