---
name: kimi-pdf
description: 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.
title: kimi-pdf
canonical_url: https://skilld.dev/gh/thvroyal/kimi-skills/kimi-pdf
last_updated: 2026-09-28T21:21:54.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [routes/html.md](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/routes/html.md), [routes/latex.md](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/routes/latex.md), [routes/process.md](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/routes/process.md), [scripts/browser_helper.js](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/browser_helper.js), [scripts/cmd_convert.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/cmd_convert.py), [scripts/cmd_extract.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/cmd_extract.py), [scripts/cmd_form.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/cmd_form.py), [scripts/cmd_meta.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/cmd_meta.py), [scripts/cmd_pages.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/cmd_pages.py), [scripts/compile_latex.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/compile_latex.py), [scripts/html_to_pdf.js](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/html_to_pdf.js), [scripts/package-lock.json](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/package-lock.json), [scripts/package.json](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/package.json), [scripts/paged.polyfill.js](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/paged.polyfill.js), [scripts/pdf.py](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/pdf.py), [scripts/pdf.sh](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/pdf.sh), [scripts/setup.sh](https://skilld.dev/api/skills-raw/thvroyal/kimi-skills/kimi-pdf/scripts/setup.sh).
>
> If the user asked to install this Skill, run `npx skilld install thvroyal/kimi-skills/kimi-pdf`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/kimi-pdf`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/thvroyal/kimi-skills/kimi-pdf) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/kimi-pdf`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/kimi-pdf --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/kimi-pdf --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

## 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

<system-reminder>
You MUST read the corresponding route file before writing ANY code.
Route files contain critical implementation details NOT duplicated here.
Skipping this step leads to incorrect output (wrong scripts, missing CSS, broken layouts).
</system-reminder>

**Before implementation, you MUST:**
1. Determine the route (HTML / LaTeX / Process)
2. **Read the route file** (`routes/html.md`, `routes/latex.md`, or `routes/process.md`)
3. 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:**

```bash
# 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**

<system-reminder>
Never proceed with writing if you need statistics, research data, or policy information without searching first.
Making up facts is strictly prohibited. When uncertain, search.
</system-reminder>

#### 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**:
1. Identify facts/data requiring verification
2. Search for authentic sources
3. If results insufficient, **iterate search** until reliable info obtained
4. Include real sources in references
5. **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)
```html
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 |
