PDFlux-PDF2Markdown
Run a JavaScript workflow that uploads a single local file to the pdflux service through PDRouter, polls the parsing status, and then downloads the resulting Markdown. This is suitable for document parsing, table extraction, content verification, and handing document content off to follow-up scripts.
Installation
CODEBLOCK0
Usage
CODEBLOCK1
Execution Constraints
- - You must invoke
scripts/upload_to_markdown.js directly. Do not reimplement the upload, polling, and Markdown download flow yourself. - The behavior contract below explains what the script does, what it outputs, and when to use it. It is not a manual checklist for the model to imitate step by step.
- Even if the task is only to extract tables, read fields, inspect body text, or prepare input for later scripts, you must run this script first and continue from the generated Markdown.
- Only inspect or modify the script implementation when the script itself is unavailable, failing, or needs a fix. Do not bypass it during normal use.
When to Use
- - Use this skill when the user wants to parse a document, retrieve specific document content, or extract tables from a document.
- Use this skill when the user says things like "convert to Markdown", "output Markdown", "export Markdown", or "extract Markdown", and return the Markdown content directly.
- When later work depends on the document content, such as summarization, field extraction, document-processing scripts, table comparison, or rule-based validation, use this skill first to parse the document.
- When the document content is only needed as input for subsequent steps, do not default to showing the full raw Markdown to the user. Prefer saving it to a temporary or working file first, then read, filter, and extract only what is needed.
- When the user explicitly asks for the original Markdown output or clearly wants a direct document-to-Markdown conversion, show the full Markdown directly.
Environment Variables
- -
PD_ROUTER_API_KEY: Required. The Bearer API key for PDRouter. If it is missing, the script fails immediately. In a skill workflow, the AI should ask the user to provide a valid key, or inject it into the environment before retrying. The API key can be obtained from the PDRouter platform: https://platform.paodingai.com/ - INLINECODE3 : Optional. Boolean. Markdown output does not include image data by default.
Security and Data Flow
- - This skill uploads one user-specified local file to the official PDRouter endpoint at
https://platform.paodingai.com. - The script reads
PD_ROUTER_API_KEY only to authenticate requests to the official PDRouter service. - The script does not print the API key to stdout or stderr.
- Generated Markdown is written to stdout and, if requested, to the user-provided output file path.
- The script does not support arbitrary network targets or custom upload hosts.
Default Behavior and Optional Settings
- - Parsed results do not include chart or image extraction by default.
- If charts, images, or similar content are required, enable them explicitly through API parameters. These results are usually returned as base64 and will increase token usage.
- Markdown output does not include image data by default. If you need embedded image data, set
PDFLUX_INCLUDE_IMAGES=true.
Script Behavior
- 1. Read the token from
PD_ROUTER_API_KEY. If it is missing, fail immediately and prompt the AI to ask the user for a key or inject the environment variable first. - Upload the file to the official PDRouter endpoint with
POST /openapi/{serviceCode}/upload using Authorization: Bearer <token>. - Poll
GET /openapi/{serviceCode}/document/{uuid} until parsed === 2. - Fail immediately if the parsing status becomes negative.
- Download the Markdown from
GET /openapi/{serviceCode}/document/{uuid}/markdown. - If
output-markdown-path is provided, the script also writes the Markdown to that file while still printing it to stdout. - The script writes progress and errors to stderr and returns a non-zero exit code on failure.
- When the goal is to retrieve specific content, fields, or tables, read the parsed result and return only the necessary information instead of echoing the full raw Markdown to the user.
- When the user explicitly asks to "convert to Markdown", "output Markdown", or expresses an equivalent intent, return the Markdown content directly rather than only a summary or extracted fields.
PDFlux-PDF2Markdown
通过PDRouter运行一个JavaScript工作流,将单个本地文件上传到pdflux服务,轮询解析状态,然后下载生成的Markdown。这适用于文档解析、表格提取、内容验证以及将文档内容传递给后续脚本。
安装
bash
npx skills add PaodingAI/skills
使用
bash
node skills/pdflux-saas-markdown/scripts/uploadtomarkdown.js <本地文件路径> [输出Markdown路径]
执行约束
- - 必须直接调用scripts/uploadtomarkdown.js。不要自行重新实现上传、轮询和Markdown下载流程。
- 以下行为契约说明了脚本的功能、输出内容以及使用时机。它不是供模型逐步模仿的手动检查清单。
- 即使任务仅涉及提取表格、读取字段、检查正文内容或为后续脚本准备输入,也必须先运行此脚本,然后基于生成的Markdown继续操作。
- 仅当脚本本身不可用、运行失败或需要修复时,才检查或修改脚本实现。在正常使用期间不要绕过它。
使用时机
- - 当用户想要解析文档、检索特定文档内容或从文档中提取表格时,使用此技能。
- 当用户说转换为Markdown、输出Markdown、导出Markdown或提取Markdown时,使用此技能并直接返回Markdown内容。
- 当后续工作依赖于文档内容(如摘要、字段提取、文档处理脚本、表格比较或基于规则的验证)时,首先使用此技能解析文档。
- 当文档内容仅作为后续步骤的输入时,默认不要向用户显示完整的原始Markdown。建议先将其保存到临时或工作文件中,然后读取、筛选并仅提取所需内容。
- 当用户明确要求原始Markdown输出或明确希望进行直接的文档到Markdown转换时,直接显示完整的Markdown。
环境变量
- - PDROUTERAPIKEY:必需。PDRouter的Bearer API密钥。如果缺失,脚本会立即失败。在技能工作流中,AI应要求用户提供有效密钥,或在重试前将其注入环境。API密钥可从PDRouter平台获取:https://platform.paodingai.com/
- PDFLUXINCLUDEIMAGES:可选。布尔值。默认情况下Markdown输出不包含图像数据。
安全与数据流
- - 此技能将用户指定的一个本地文件上传到官方PDRouter端点https://platform.paodingai.com。
- 脚本仅读取PDROUTERAPI_KEY以验证对官方PDRouter服务的请求。
- 脚本不会将API密钥打印到标准输出或标准错误输出。
- 生成的Markdown写入标准输出,如果指定了输出文件路径,也会写入该文件。
- 脚本不支持任意网络目标或自定义上传主机。
默认行为与可选设置
- - 默认情况下,解析结果不包含图表或图像提取。
- 如果需要图表、图像或类似内容,请通过API参数显式启用。这些结果通常以base64格式返回,会增加令牌使用量。
- 默认情况下Markdown输出不包含图像数据。如果需要嵌入图像数据,请设置PDFLUXINCLUDEIMAGES=true。
脚本行为
- 1. 从PDROUTERAPI_KEY读取令牌。如果缺失,立即失败并提示AI要求用户提供密钥或先注入环境变量。
- 使用POST /openapi/{serviceCode}/upload将文件上传到官方PDRouter端点,使用Authorization: Bearer 。
- 轮询GET /openapi/{serviceCode}/document/{uuid},直到parsed === 2。
- 如果解析状态变为负数,立即失败。
- 从GET /openapi/{serviceCode}/document/{uuid}/markdown下载Markdown。
- 如果提供了output-markdown-path,脚本还会将Markdown写入该文件,同时仍将其打印到标准输出。
- 脚本将进度和错误信息写入标准错误输出,并在失败时返回非零退出码。
- 当目标是检索特定内容、字段或表格时,读取解析结果并仅返回必要信息,而不是将完整的原始Markdown回显给用户。
- 当用户明确要求转换为Markdown、输出Markdown或表达类似意图时,直接返回Markdown内容,而不是仅返回摘要或提取的字段。