@liustack/pagepress 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.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/README.zh-CN.md +82 -0
- package/dist/main.js +528 -0
- package/package.json +59 -0
- package/src/pdf/templates/default.html +555 -0
- package/src/pdf/templates/github.html +316 -0
- package/src/pdf/templates/magazine.html +452 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Leon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# PagePress
|
|
2
|
+
|
|
3
|
+
A web content rendering toolkit (CLI) designed for **AI Agents**, converting HTML, Markdown, and URLs into high-quality **PDF** or **PNG** images.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- **Unified CLI**: One tool (`pagepress`) for both PDF and image generation
|
|
8
|
+
- **AI Agent friendly**: Includes a detailed SKILL.md guide with scenario routing
|
|
9
|
+
- **Multiple inputs**: Local HTML, Markdown files, or remote URLs
|
|
10
|
+
- **Rich templates**:
|
|
11
|
+
- **PDF**: Apple style, GitHub style, magazine layout (Magazine)
|
|
12
|
+
- **Image**: OG cards, infographics, posters, banners
|
|
13
|
+
- **Consistency guarantees**: Deterministic rendering, font waiting, network idle detection, syntax highlighting
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Global install
|
|
19
|
+
npm install -g @liustack/pagepress
|
|
20
|
+
|
|
21
|
+
# Install browsers (Playwright)
|
|
22
|
+
npx playwright install chromium
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or use `npx` directly:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx @liustack/pagepress <command> [options]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 🚀 Usage
|
|
32
|
+
|
|
33
|
+
### 1. Generate PDF
|
|
34
|
+
|
|
35
|
+
Convert HTML/Markdown into PDF documents. Supports syntax highlighting.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Markdown to PDF (Apple style template)
|
|
39
|
+
pagepress pdf -i document.md -o output.pdf --template default
|
|
40
|
+
|
|
41
|
+
# Local HTML file to PDF
|
|
42
|
+
pagepress pdf -i page.html -o output.pdf
|
|
43
|
+
|
|
44
|
+
# Render a web page (as-is)
|
|
45
|
+
pagepress pdf -i https://example.com -o webpage.pdf
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Supported templates**:
|
|
49
|
+
- `default` - Apple style, clean and elegant
|
|
50
|
+
- `github` - GitHub style
|
|
51
|
+
- `magazine` - VOGUE/WIRED magazine layout
|
|
52
|
+
|
|
53
|
+
### 2. Generate Images
|
|
54
|
+
|
|
55
|
+
Render HTML/URLs into PNG images, suitable for social share cards, posters, and long screenshots.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Generate an OG card (1200x630)
|
|
59
|
+
pagepress shot -i card.html -o og.png --preset og
|
|
60
|
+
|
|
61
|
+
# Generate a long infographic
|
|
62
|
+
pagepress shot -i stats.html -o infographic.png --preset infographic
|
|
63
|
+
|
|
64
|
+
# Webpage screenshot
|
|
65
|
+
pagepress shot -i https://example.com -o screenshot.png
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Supported presets**:
|
|
69
|
+
- `og` (1200x630) - Social card
|
|
70
|
+
- `infographic` (1080x1350) - Infographic
|
|
71
|
+
- `poster` (1200x1500) - Poster
|
|
72
|
+
- `banner` (1600x900) - Banner
|
|
73
|
+
|
|
74
|
+
## 🤖 AI Agent Integration
|
|
75
|
+
|
|
76
|
+
This project includes a detailed [SKILL.md](skills/pagepress/SKILL.md) to help AI Agents (such as Claude, ChatGPT) understand how to use this tool.
|
|
77
|
+
|
|
78
|
+
Agents can automatically choose the appropriate commands and parameters based on natural language instructions (for example, "generate a poster" or "convert this document to PDF").
|
|
79
|
+
|
|
80
|
+
## 📄 License
|
|
81
|
+
|
|
82
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# PagePress
|
|
2
|
+
|
|
3
|
+
一套专为 **AI Agent** 设计的 Web 内容渲染工具集(CLI),可将 HTML、Markdown、URL 转换为高质量的 **PDF** 或 **PNG** 图像。
|
|
4
|
+
|
|
5
|
+
## ✨ 特性
|
|
6
|
+
|
|
7
|
+
- **统一 CLI**:一个工具 (`pagepress`) 搞定 PDF 和 Image 生成
|
|
8
|
+
- **AI Agent 友好**:包含详细的 SKILL.md 指南,支持场景路由
|
|
9
|
+
- **多种输入**:支持本地 HTML、Markdown 文件或远程 URL
|
|
10
|
+
- **丰富模板**:
|
|
11
|
+
- **PDF**: Apple 风格、GitHub 风格、杂志排版 (Magazine)
|
|
12
|
+
- **Image**: OG 卡片、信息图、海报、横幅
|
|
13
|
+
- **一致性保障**:确定性渲染、字体等待、网络空闲检测、代码高亮
|
|
14
|
+
|
|
15
|
+
## 📦 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 全局安装
|
|
19
|
+
npm install -g @liustack/pagepress
|
|
20
|
+
|
|
21
|
+
# 安装浏览器(Playwright)
|
|
22
|
+
npx playwright install chromium
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
或者直接使用 `npx`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx @liustack/pagepress <command> [options]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 🚀 使用指南
|
|
32
|
+
|
|
33
|
+
### 1. 生成 PDF
|
|
34
|
+
|
|
35
|
+
将 HTML/Markdown 转换为 PDF 文档。支持代码高亮。
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Markdown 转 PDF(使用 Apple 风格模板)
|
|
39
|
+
pagepress pdf -i document.md -o output.pdf --template default
|
|
40
|
+
|
|
41
|
+
# 本地 HTML 文件转 PDF
|
|
42
|
+
pagepress pdf -i page.html -o output.pdf
|
|
43
|
+
|
|
44
|
+
# 网页打印(原样渲染)
|
|
45
|
+
pagepress pdf -i https://example.com -o webpage.pdf
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**支持的模板**:
|
|
49
|
+
- `default` - Apple 风格,简洁优雅
|
|
50
|
+
- `github` - GitHub 风格
|
|
51
|
+
- `magazine` - VOGUE/WIRED 杂志排版
|
|
52
|
+
|
|
53
|
+
### 2. 生成图像
|
|
54
|
+
|
|
55
|
+
将 HTML/URL 渲染为 PNG 图像,适合社交分享卡片、海报、长图截屏。
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 生成 OG 卡片(1200×630)
|
|
59
|
+
pagepress shot -i card.html -o og.png --preset og
|
|
60
|
+
|
|
61
|
+
# 生成信息长图
|
|
62
|
+
pagepress shot -i stats.html -o infographic.png --preset infographic
|
|
63
|
+
|
|
64
|
+
# 网页截图
|
|
65
|
+
pagepress shot -i https://example.com -o screenshot.png
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**支持的预设**:
|
|
69
|
+
- `og` (1200×630) - 社交卡片
|
|
70
|
+
- `infographic` (1080×1350) - 信息图
|
|
71
|
+
- `poster` (1200×1500) - 海报
|
|
72
|
+
- `banner` (1600×900) - 横幅
|
|
73
|
+
|
|
74
|
+
## 🤖 AI Agent 集成
|
|
75
|
+
|
|
76
|
+
本项目包含详细的 [SKILL.md](skills/pagepress/SKILL.md),旨在帮助 AI Agent(如 Claude, ChatGPT)理解如何使用此工具。
|
|
77
|
+
|
|
78
|
+
Agent 可以根据用户的自然语言指令(如“生成一张海报”、“把这个文档转成 PDF”)自动选择合适的命令和参数。
|
|
79
|
+
|
|
80
|
+
## 📄 License
|
|
81
|
+
|
|
82
|
+
MIT
|