Route Selection
| Route |
Trigger |
Route File |
| HTML (default) |
All PDF creation requests |
routes/html.md |
| LaTeX |
User explicitly requests LaTeX, .tex, or Tectonic |
routes/latex.md |
| Process |
Work with existing PDFs (extract, merge, fill forms, etc.) |
routes/process.md |
Default to HTML. Only use LaTeX route when user explicitly requests it.
MANDATORY: Read Route File Before Implementation
Before implementation, you MUST:
- Determine the route (HTML / LaTeX / Process)
- Read the route file (
routes/html.md, routes/latex.md, or routes/process.md)
- Only then proceed with implementation
This file (SKILL.md) contains constraints and principles. Route files contain how-to details.
Decision Rules
Route Selection
| User Says |
Route |
| "Create a PDF", "Make a report", "Write a paper" |
HTML |
| "Use LaTeX", "Compile .tex", "Use Tectonic" |
LaTeX |
| "Extract text from PDF", "Merge these PDFs", "Fill this form" |
Process |
Cover Style Selection (HTML Route)
| Context |
Style |
| Academic paper, thesis, formal coursework |
Minimal (white, centered, no decoration) |
| Reports, proposals, professional documents |
Designed (choose from style reference in html.md) |
| Uncertain |
Default to Designed — plain text cover = mediocre |
Key principle: Cover background separates "acceptable" from "impressive". See html.md for 11 style options.
Citation Format Selection
| Document Language |
Format |
| Chinese |
GB/T 7714 (use [J][M][D] identifiers) |
| English |
APA |
| Mixed |
Chinese refs → GB/T 7714, English refs → APA |
Quick Start
Use the unified CLI for all operations:
# Check environment (JSON output, exit code 0=ok, 2=missing deps)
/app/.kimi/skills/kimi-pdf/scripts/pdf.sh check
# Auto-fix missing dependencies (idempotent, safe to run multiple times)
/app/.kimi/skills/kimi-pdf/scripts/pdf.sh fix
# Convert HTML to PDF
/app/.kimi/skills/kimi-pdf/scripts/pdf.sh html input.html
# Compile LaTeX to PDF
/app/.kimi/skills/kimi-pdf/scripts/pdf.sh latex input.tex
Exit codes:
0 = success
1 = usage error
2 = dependency missing (run pdf.sh fix)
3 = runtime error
Dependencies by route:
- HTML route: Node.js, Playwright, Chromium
- Process route: Python 3, pikepdf, pdfplumber
- LaTeX route: Tectonic
Core Constraints (Must Follow)
1. Output Language
Output language must match user's query language.
- User writes in Chinese → PDF content in Chinese
- User writes in English → PDF content in English
- User explicitly specifies language → Follow user's specification
2. Word Count and Page Constraints
- Strictly follow user-specified word/page count requirements
- Do not arbitrarily inflate content length
3. Citation and Search Standards
CRITICAL: Search Before Writing
DO NOT fabricate information. When in doubt, SEARCH.
If content involves ANY of these, you MUST search FIRST before writing:
- Statistics, numbers, percentages, rankings
- Policies, regulations, laws, standards
- Academic research, theories, methodologies
- Current events, recent developments
- Anything you're not 100% certain about
When Search is Required
| Scenario |
Search? |
Notes |
| Statistics, data |
Required |
e.g., "2024 employment rate" |
| Policies, regulations |
Required |
e.g., "startup subsidies" |
| Research, papers |
Required |
e.g., "effectiveness of method X" |
| Time-sensitive content |
Required |
Information after knowledge cutoff |
| Uncertain facts |
Required |
If unsure, always search |
| Common knowledge |
Not needed |
e.g., "water boils at 100°C" |
Search workflow:
- Identify facts/data requiring verification
- Search for authentic sources
- If results insufficient, iterate search until reliable info obtained
- Include real sources in references
- If search fails repeatedly, tell the user instead of making up data
Citations Must Be Real
Fabricating references is prohibited. All citations must have:
- Correct author/institution names
- Accurate titles
- Verifiable year, journal/source
Cross-references (Must Be Clickable)
As shown in <a href="#fig-1-1">Figure 1-1</a>...
From <a href="#eq-2-1">Equation (2-1)</a>...
See <a href="#sec3">Section 3</a>...
Note: id must be placed at container top (see CSS Counters section in html.md).
Content Quality Constraints
1. Word/Page Count Constraints
Must strictly follow user-specified word or page count requirements:
| User Request |
Execution Standard |
| Specific word count (e.g., "3000 words") |
Within ±20%, i.e., 2400-3600 words |
| Specific page count (e.g., "5 pages") |
Exactly equal, last page may be partial |
| Word count range (e.g., "2000-3000 words") |
Must fall within range |
| No explicit requirement |
Infer reasonably by document type; prefer thorough over superficial |
| Minimum specified (e.g., "more than 5000 words") |
No more than 2x, i.e., 5000-10000 words |
Prohibited behaviors:
- Arbitrarily shortening content ("concise" is not an excuse)
- Padding pages with excessive bullet lists (maintain high information density)
- Exceeding twice the user's requested length
Special case - Resume/CV:
- Resume should be 1 page unless user specifies otherwise
- Use compact margins:
margin: 1.5cm
2. Outline Adherence (Mandatory)
When user provides outline:
- Strictly follow the user-provided outline structure
- Section titles must match outline (minor wording adjustments OK, no level/order changes)
- Do not add or remove sections arbitrarily
- If outline seems problematic, ask user first before modifying
When no user outline:
- Use standard structures based on document type:
- Academic papers: IMRaD (Introduction-Methods-Results-Discussion) or Introduction-Literature Review-Methods-Results-Discussion-Conclusion
- Business reports: Conclusion-first (Executive Summary → Detailed Analysis → Recommendations)
- Technical docs: Overview → Principles → Usage → Examples → FAQ
- Course assignments: Follow assignment structure requirements
- Sections must have logical progression, no disconnects
Tech Stack Overview
| Route |
Tools |
Purpose |
| HTML |
Playwright + Paged.js |
HTML → PDF conversion |
| HTML |
KaTeX, Mermaid |
Math formulas, diagrams |
| Process |
pikepdf |
Form filling, page operations, metadata |
| Process |
pdfplumber |
Text and table extraction |
| Process |
LibreOffice |
Office → PDF conversion |
| LaTeX |
Tectonic |
LaTeX → PDF compilation |
1---2name: kimi-pdf3description: Professional PDF solution. Create PDFs using HTML+Paged.js (academic papers, reports, documents). Process existing PDFs using Python (read, extract, merge, split, fill forms). Supports KaTeX math formulas, Mermaid diagrams, three-line tables, citations, and other academic elements. Also use this skill when user explicitly requests LaTeX (.tex) or native LaTeX compilation.4---5
6## Route Selection
7
8| Route | Trigger | Route File |
9|-------|---------|------------|
10| **HTML** (default) | All PDF creation requests | `routes/html.md` |
11| **LaTeX** | User explicitly requests LaTeX, .tex, or Tectonic | `routes/latex.md` |
12| **Process** | Work with existing PDFs (extract, merge, fill forms, etc.) | `routes/process.md` |
13
14**Default to HTML.** Only use LaTeX route when user explicitly requests it.
15
16### MANDATORY: Read Route File Before Implementation
17
18<system-reminder>
19You MUST read the corresponding route file before writing ANY code.
20Route files contain critical implementation details NOT duplicated here.
21Skipping this step leads to incorrect output (wrong scripts, missing CSS, broken layouts).
22</system-reminder>
23
24**Before implementation, you MUST:**
251. Determine the route (HTML / LaTeX / Process)
262. **Read the route file** (`routes/html.md`, `routes/latex.md`, or `routes/process.md`)
273. Only then proceed with implementation
28
29This file (SKILL.md) contains constraints and principles. Route files contain **how-to details**.
30
31### Decision Rules
32
33#### Route Selection
34| User Says | Route |
35|-----------|-------|
36| "Create a PDF", "Make a report", "Write a paper" | HTML |
37| "Use LaTeX", "Compile .tex", "Use Tectonic" | LaTeX |
38| "Extract text from PDF", "Merge these PDFs", "Fill this form" | Process |
39
40#### Cover Style Selection (HTML Route)
41| Context | Style |
42|---------|-------|
43| Academic paper, thesis, formal coursework | **Minimal** (white, centered, no decoration) |
44| Reports, proposals, professional documents | **Designed** (choose from style reference in html.md) |
45| Uncertain | Default to **Designed** — plain text cover = mediocre |
46
47**Key principle**: Cover background separates "acceptable" from "impressive". See html.md for 11 style options.
48
49#### Citation Format Selection
50| Document Language | Format |
51|-------------------|--------|
52| Chinese | GB/T 7714 (use [J][M][D] identifiers) |
53| English | APA |
54| Mixed | Chinese refs → GB/T 7714, English refs → APA |
55
56---
57
58## Quick Start
59
60**Use the unified CLI for all operations:**
61
62```bash
63# Check environment (JSON output, exit code 0=ok, 2=missing deps)
64/app/.kimi/skills/kimi-pdf/scripts/pdf.sh check
65
66# Auto-fix missing dependencies (idempotent, safe to run multiple times)
67/app/.kimi/skills/kimi-pdf/scripts/pdf.sh fix
68
69# Convert HTML to PDF
70/app/.kimi/skills/kimi-pdf/scripts/pdf.sh html input.html
71
72# Compile LaTeX to PDF
73/app/.kimi/skills/kimi-pdf/scripts/pdf.sh latex input.tex
74```
75
76**Exit codes:**
77- `0` = success
78- `1` = usage error
79- `2` = dependency missing (run `pdf.sh fix`)
80- `3` = runtime error
81
82**Dependencies by route:**
83- **HTML route**: Node.js, Playwright, Chromium
84- **Process route**: Python 3, pikepdf, pdfplumber
85- **LaTeX route**: Tectonic
86
87---
88
89## Core Constraints (Must Follow)
90
91### 1. Output Language
92**Output language must match user's query language.**
93- User writes in Chinese → PDF content in Chinese
94- User writes in English → PDF content in English
95- User explicitly specifies language → Follow user's specification
96
97### 2. Word Count and Page Constraints
98- Strictly follow user-specified word/page count requirements
99- Do not arbitrarily inflate content length
100
101### 3. Citation and Search Standards
102
103#### CRITICAL: Search Before Writing
104**DO NOT fabricate information. When in doubt, SEARCH.**
105
106If content involves ANY of these, you **MUST search FIRST** before writing:
107- Statistics, numbers, percentages, rankings
108- Policies, regulations, laws, standards
109- Academic research, theories, methodologies
110- Current events, recent developments
111- **Anything you're not 100% certain about**
112
113<system-reminder>
114Never proceed with writing if you need statistics, research data, or policy information without searching first.
115Making up facts is strictly prohibited. When uncertain, search.
116</system-reminder>
117
118#### When Search is Required
119| Scenario | Search? | Notes |
120|----------|---------|-------|
121| Statistics, data | **Required** | e.g., "2024 employment rate" |
122| Policies, regulations | **Required** | e.g., "startup subsidies" |
123| Research, papers | **Required** | e.g., "effectiveness of method X" |
124| Time-sensitive content | **Required** | Information after knowledge cutoff |
125| **Uncertain facts** | **Required** | If unsure, always search |
126| Common knowledge | Not needed | e.g., "water boils at 100°C" |
127
128**Search workflow**:
1291. Identify facts/data requiring verification
1302. Search for authentic sources
1313. If results insufficient, **iterate search** until reliable info obtained
1324. Include real sources in references
1335. **If search fails repeatedly, tell the user** instead of making up data
134
135#### Citations Must Be Real
136**Fabricating references is prohibited**. All citations must have:
137- Correct author/institution names
138- Accurate titles
139- Verifiable year, journal/source
140
141#### Cross-references (Must Be Clickable)
142```html
143As shown in <a href="#fig-1-1">Figure 1-1</a>...
144From <a href="#eq-2-1">Equation (2-1)</a>...
145See <a href="#sec3">Section 3</a>...
146```
147**Note**: `id` must be placed at container top (see CSS Counters section in html.md).
148
149---
150
151## Content Quality Constraints
152
153### 1. Word/Page Count Constraints
154**Must strictly follow user-specified word or page count requirements**:
155
156| User Request | Execution Standard |
157|--------------|-------------------|
158| Specific word count (e.g., "3000 words") | Within ±20%, i.e., 2400-3600 words |
159| Specific page count (e.g., "5 pages") | Exactly equal, last page may be partial |
160| Word count range (e.g., "2000-3000 words") | Must fall within range |
161| No explicit requirement | Infer reasonably by document type; prefer thorough over superficial |
162| Minimum specified (e.g., "more than 5000 words") | No more than 2x, i.e., 5000-10000 words |
163
164**Prohibited behaviors**:
165- Arbitrarily shortening content ("concise" is not an excuse)
166- Padding pages with excessive bullet lists (maintain high information density)
167- Exceeding twice the user's requested length
168
169**Special case - Resume/CV**:
170- Resume should be **1 page** unless user specifies otherwise
171- Use compact margins: `margin: 1.5cm`
172
173### 2. Outline Adherence (Mandatory)
174**When user provides outline**:
175- **Strictly follow** the user-provided outline structure
176- Section titles must match outline (minor wording adjustments OK, no level/order changes)
177- Do not add or remove sections arbitrarily
178- If outline seems problematic, **ask user first** before modifying
179
180**When no user outline**:
181- Use standard structures based on document type:
182 - **Academic papers**: IMRaD (Introduction-Methods-Results-Discussion) or Introduction-Literature Review-Methods-Results-Discussion-Conclusion
183 - **Business reports**: Conclusion-first (Executive Summary → Detailed Analysis → Recommendations)
184 - **Technical docs**: Overview → Principles → Usage → Examples → FAQ
185 - **Course assignments**: Follow assignment structure requirements
186- Sections must have logical progression, no disconnects
187
188---
189
190## Tech Stack Overview
191
192| Route | Tools | Purpose |
193|-------|-------|---------|
194| HTML | Playwright + Paged.js | HTML → PDF conversion |
195| HTML | KaTeX, Mermaid | Math formulas, diagrams |
196| Process | pikepdf | Form filling, page operations, metadata |
197| Process | pdfplumber | Text and table extraction |
198| Process | LibreOffice | Office → PDF conversion |
199| LaTeX | Tectonic | LaTeX → PDF compilation |