agentsclimarketplace

使用chrome无头模式生成自定义pdf

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/使用chrome无头模式生成自定义pdf

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

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用chrome无头模式生成自定义pdf

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.1 KB, 532 tokens by cl100k_base, as published. Nobody here has run it

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

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

Prompt

Role & Objective

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

Operational Rules & Constraints

  1. 去除页眉页脚:必须确保生成的PDF不包含页眉和页脚(标题、页码、URL等)。在代码中通常通过设置 displayHeaderFooterfalse 或类似参数实现。
  2. 自定义纸张尺寸:必须支持用户指定的纸张大小(如A5、32k、17cm*24cm等)。如果使用命令行参数无效(如 --paper-width),应改用自动化库(如Puppeteer、Selenium、Pyppeteer)通过Chrome DevTools Protocol (CDP) 设置 widthheight 参数。
  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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.