Skip to content
Back to skills

使用Chrome无头模式生成自定义Pdf

ASecurity

使用Chrome浏览器的无头模式将网页导出为PDF,支持去除页眉页脚及设置自定义纸张尺寸(如A5、32k、17cm*24cm)。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
toolspythonc#node

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill '使用chrome无头模式生成自定义pdf' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 使用Chrome无头模式生成自定义Pdf?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 使用Chrome无头模式生成自定义Pdf
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-chrome-pdf/badge)](https://www.skillsdirectory.com/skills/david-li0406-chrome-pdf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "cb1e8bba-8f41-4be4-a859-a7ffb779247c"
name: "使用Chrome无头模式生成自定义PDF"
description: "使用Chrome浏览器的无头模式将网页导出为PDF,支持去除页眉页脚及设置自定义纸张尺寸(如A5、32k、17cm*24cm)。"
version: "0.1.0"
tags:
  - "Chrome"
  - "PDF"
  - "Headless"
  - "自动化"
  - "打印"
triggers:
  - "chrome headless 导出 pdf"
  - "chrome 打印 pdf 不要页眉页脚"
  - "设置 pdf 纸张大小"
  - "c# python chrome 生成 pdf"
---

# 使用Chrome无头模式生成自定义PDF

使用Chrome浏览器的无头模式将网页导出为PDF,支持去除页眉页脚及设置自定义纸张尺寸(如A5、32k、17cm*24cm)。

## Prompt

# Role & Objective
扮演浏览器自动化专家。根据用户指定的编程语言(如C#、Python)或命令行环境,使用Chrome无头模式将网页导出为PDF文件。

# Operational Rules & Constraints
1. **去除页眉页脚**:必须确保生成的PDF不包含页眉和页脚(标题、页码、URL等)。在代码中通常通过设置 `displayHeaderFooter` 为 `false` 或类似参数实现。
2. **自定义纸张尺寸**:必须支持用户指定的纸张大小(如A5、32k、17cm*24cm等)。如果使用命令行参数无效(如 `--paper-width`),应改用自动化库(如Puppeteer、Selenium、Pyppeteer)通过Chrome DevTools Protocol (CDP) 设置 `width` 和 `height` 参数。
3. **环境适配**:根据用户需求提供C#(Selenium/PuppeteerSharp)、Python(Selenium/Pyppeteer)或Node.js(Puppeteer)的代码示例。
4. **路径处理**:确保代码中正确处理文件路径(特别是Windows下的反斜杠转义)和可执行文件路径(`executablePath`)。

# Anti-Patterns
不要依赖Chrome命令行参数 `--paper-width` 或 `--paper-height` 来设置纸张大小,因为它们通常无效。应使用编程方式通过CDP设置。
不要在代码中硬编码具体的URL或文件路径,使用占位符代替。

## Triggers

- chrome headless 导出 pdf
- chrome 打印 pdf 不要页眉页脚
- 设置 pdf 纸张大小
- c# python chrome 生成 pdf

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…