Pdfporter

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.1.0更新于 Nov 5, 2026

Convert files/URLs to PDF via conv2pdf; writes output files locally and deletes conversion jobs.

已验证STDIO仅桌面效率与工作流文件与存储

概览

AI 生成的概览

conv2pdf 服务的客户端,可将本地文件和网页转换为 PDF,并对 PDF 做合并、拆分、压缩、加密等处理,结果写入本地磁盘。

可以做什么
  • 按扩展名把本地文件转换为 PDF,或把公开网页渲染为 PDF
  • 把 PDF 转为可编辑的 Word 文档或逐页 PNG/JPG 压缩包,把 HEIC 照片转为 JPG
  • 合并、拆分、按页码范围提取、旋转、加页码和水印
  • 压缩 PDF,设置或移除密码及打印、复制限制
  • 查询 API 密钥的套餐、用量和限额
适用场景
适合需要把 Office 文档、图片、电子书或网页转成 PDF,或在用户机器上合并、拆分、压缩、加水印、加密 PDF 而无需本地办公套件的场景。
运行要求
通过 npx 或 Docker 在本地运行。需要在 CONV2PDF_API_KEY 中提供 conv2pdf API 密钥,以 Bearer 方式发送;可选 CONV2PDF_API_URL 和 CONV2PDF_TIMEOUT_MS。每次工具调用都需要访问 conv2pdf API 的网络;没有密钥时服务器仍可启动,但调用会失败。
安装前请注意
每次转换都会把输入文件或网址上传到第三方 conv2pdf 服务,机密文档需谨慎。protect_pdf 和 unlock_pdf 的密码会传给该服务。工具会写入磁盘文件,并拒绝覆盖已有输出。用量计入 API 密钥的套餐配额。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pdfporter,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

pdfporter

Files in, PDFs out — and PDFs reshaped. pdfporter is a client for the conv2pdf conversion service: it takes the path of a file on your computer, sends it for conversion, and writes the result back next to the original. Office documents, spreadsheets, presentations, images, e-books, PostScript and HTML files become PDFs; PDFs become Word documents or per-page images; and PDFs can be merged, split, page-extracted, rotated, numbered, watermarked, compressed, password-protected and unlocked.

Configuration

  • CONV2PDF_API_KEY (required for calls) — created in the conv2pdf dashboard, Developer tab. It is sent on every request as Authorization: Bearer <key>. Without a key the server still starts and lists its tools; any tool call fails with a message explaining how to set the key.
  • CONV2PDF_API_URL (optional) — API base URL. Defaults to https://api.conv2pdf.com/v1.
  • CONV2PDF_TIMEOUT_MS (optional) — per-request timeout in milliseconds. Defaults to 120000, because a conversion may legitimately take up to about a minute.

Tools

  • convert_to_pdf — convert a file to PDF, chosen from its extension: Word, Excel, PowerPoint, OpenDocument, Apple Pages, RTF, TXT and CSV files go through office-to-pdf; PNG, JPG, WebP, GIF and TIFF images through image-to-pdf; HEIC/HEIF photos through heic-to-pdf; EPUB through epub-to-pdf; PS/EPS through ps-to-pdf; HTML through html-to-pdf. An unknown extension fails locally, with no request made.
  • convert_url_to_pdf — render a public web page to PDF from its address. It always takes an output_path, because there is no input file to write next to.
  • convert_heic_to_jpg — an iPhone HEIC or HEIF photo as a JPG.
  • convert_pdf_to_word — a PDF with real text as an editable DOCX document. Pass password to open a protected PDF.
  • convert_pdf_to_images — one PNG (default) or JPG per page, delivered in a ZIP file.
  • merge_pdfs — combine 2 to 20 PDFs into one, in the order given in paths.
  • extract_pdf_pages — copy the pages listed in ranges (such as 1-5,7,10-12) into a new PDF, in the order written.
  • split_pdf — one PDF per page, in a ZIP file.
  • rotate_pdf — turn every page by rotation: 90, 180 or 270 degrees.
  • add_page_numbers — number the pages, as "3 / 12" (format: "full", the default) or "3" (format: "simple"), at position bottom-center (default), bottom-left or bottom-right.
  • add_watermark — stamp a text of up to 50 characters on every page.
  • compress_pdf — reduce the size, with quality low, medium (default) or high, keeping images at 72, 150 or 300 DPI.
  • protect_pdf — set a new password (6 to 64 characters), with prevent_print and prevent_copy to forbid printing or copying.
  • unlock_pdf — remove a password you know (pass it as password), or the printing and copying restrictions.
  • get_quota — the plan, usage and limits of the API key, returned verbatim.

Most PDF-reading tools accept an optional password that opens a protected PDF; the result has no password.

How a conversion behaves

  1. The input file is read locally and POSTed as multipart/form-data to <base>/convert/<api-tool>, the file in the file field plus the tool's fields as string fields.
  2. On HTTP 429 or 503 the server waits for the delay the API gives (the Retry-After header, else the body's retry_after seconds) and retries, at most twice and only for delays of 30 seconds or less.
  3. The convert response carries a job_id and a relative download_url; the result is downloaded from the API origin, written to disk, and the job is then deleted from the service on a best-effort basis.

Results are never overwritten. By default the output sits next to the input: a conversion swaps the extension (report.docx gives report.pdf), a PDF operation adds a suffix (report.pdf gives report-compressed.pdf for compress_pdf, report-images.zip for convert_pdf_to_images, and so on), and a merge writes merged.pdf next to the first input. When the target name is taken, (2), (3), ... is appended before the extension until a free name is found. With an explicit output_path, an existing file there is refused before anything is sent.

A successful conversion answers with a JSON summary: {"job_id": ..., "output_path": ..., "size_bytes": ...}, plus the quota object copied from the convert response when the service sends one. get_quota returns the service's response body verbatim.

Errors: a non-2xx reply fails with conv2pdf error: <error> when the body carries an error code, else conv2pdf error: HTTP <status>; an unreachable API fails with conv2pdf unreachable.

CLI

Each tool is a subcommand taking one JSON argument string:

bash
npx @reneturcios/pdfporter convert_to_pdf '{"path":"report.docx"}'npx @reneturcios/pdfporter convert_url_to_pdf '{"url":"https://example.com/article","output_path":"article.pdf"}'npx @reneturcios/pdfporter convert_heic_to_jpg '{"path":"IMG_0001.heic"}'npx @reneturcios/pdfporter convert_pdf_to_word '{"path":"report.pdf"}'npx @reneturcios/pdfporter convert_pdf_to_images '{"path":"report.pdf","format":"jpg"}'npx @reneturcios/pdfporter merge_pdfs '{"paths":["a.pdf","b.pdf"]}'npx @reneturcios/pdfporter extract_pdf_pages '{"path":"report.pdf","ranges":"1-5,7,10-12"}'npx @reneturcios/pdfporter split_pdf '{"path":"report.pdf"}'npx @reneturcios/pdfporter rotate_pdf '{"path":"scan.pdf","rotation":90}'npx @reneturcios/pdfporter add_page_numbers '{"path":"report.pdf","position":"bottom-right"}'npx @reneturcios/pdfporter add_watermark '{"path":"contract.pdf","text":"CONFIDENTIAL"}'npx @reneturcios/pdfporter compress_pdf '{"path":"big.pdf","quality":"low"}'npx @reneturcios/pdfporter protect_pdf '{"path":"confidential.pdf","password":"secret123","prevent_print":true}'npx @reneturcios/pdfporter unlock_pdf '{"path":"protected.pdf","password":"secret123"}'npx @reneturcios/pdfporter get_quota '{}'npx @reneturcios/pdfporter --version

Exit codes: 0 on success, 1 on a runtime error, 2 on a usage error.

MCP server

bash
npx -y @reneturcios/pdfporter mcp

MCP client config:

json
{  "mcpServers": {    "pdfporter": {      "command": "npx",      "args": ["-y", "@reneturcios/pdfporter", "mcp"],      "env": {        "CONV2PDF_API_KEY": "<your key>"      }    }  }}

Docker

bash
docker run -i ghcr.io/cloudcorprecords/pdfporterdocker run --rm ghcr.io/cloudcorprecords/pdfporter get_quota '{}'

Development

bash
npm installnpm run build   # tsc -> dist/npm test        # tsx --test test/*.test.ts (fake fetch only, no network)npm run dev     # run the CLI from source

License

MIT — Copyright (c) 2026 Rene Turcios

来源:README.md,提交 6294b71

工具

15

convert_to_pdf

Word, Excel, PowerPoint, OpenDocument, Apple Pages, RTF, TXT, CSV, PNG, JPG, WebP, GIF, TIFF, HEIC, EPUB, PostScript (PS, EPS) or HTML file to PDF, chosen from the extension. Reads the local file, uploads it to the conv2pdf API, writes the converted PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填output_path

convert_url_to_pdf

Public web page to PDF, from its address, printed as a browser would. Sends the URL to the conv2pdf API, writes the resulting PDF to the local output_path and deletes the conversion job afterwards.

输入参数url必填output_path必填

convert_heic_to_jpg

iPhone HEIC or HEIF photo to JPG. Reads the local file, uploads it to the conv2pdf API, writes the JPG to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填output_path

convert_pdf_to_word

PDF with real text to an editable DOCX document. Reads the local file, uploads it to the conv2pdf API, writes the DOCX to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填passwordoutput_path

convert_pdf_to_images

One PNG or JPG per page, in a ZIP file. Reads the local file, uploads it to the conv2pdf API, writes the ZIP to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填formatpasswordoutput_path

merge_pdfs

Combine several PDFs into one, in the order given. Reads the local files, uploads them to the conv2pdf API, writes the merged PDF to output_path (or next to the first input) and deletes the conversion job afterwards.

输入参数paths必填output_path

extract_pdf_pages

Copy the pages you list, such as 1-5,7,10-12, into a new PDF, in the order written. Reads the local file, uploads it to the conv2pdf API, writes the new PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填ranges必填passwordoutput_path

split_pdf

One PDF per page, in a ZIP file. Reads the local file, uploads it to the conv2pdf API, writes the ZIP to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填passwordoutput_path

rotate_pdf

Turn every page by 90, 180 or 270 degrees. Reads the local file, uploads it to the conv2pdf API, writes the rotated PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填passwordrotation必填output_path

add_page_numbers

Number the pages, as "3 / 12" or "3", bottom center, left or right. Reads the local file, uploads it to the conv2pdf API, writes the numbered PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填formatpasswordpositionoutput_path

add_watermark

Stamp a text of up to 50 characters on every page. Reads the local file, uploads it to the conv2pdf API, writes the watermarked PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填text必填passwordoutput_path

compress_pdf

Reduce the size, keeping images at 72, 150 or 300 DPI. Reads the local file, uploads it to the conv2pdf API, writes the compressed PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填qualitypasswordoutput_path

protect_pdf

Set a password, and optionally forbid printing or copying. Reads the local file, uploads it to the conv2pdf API, writes the protected PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填password必填output_pathprevent_copyprevent_print

unlock_pdf

Remove a password you know, or the printing and copying restrictions. Reads the local file, uploads it to the conv2pdf API, writes the unlocked PDF to output_path (or next to the input) and deletes the conversion job afterwards.

输入参数path必填passwordoutput_path

get_quota

Plan, usage and limits of the API key

无需输入参数。

版本历史

1
  1. v0.1.0最新Nov 5, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分