Logo Pdf Extract Template

Pdf Extract Template

Tổ chức
okou-ai
pdf-extract-template

Extract a template skill from a PDF document for filling slots, reusing structure and expression, or applying its visual style. Use when asked to extract a PDF template or its styles, turn a PDF into a Word template, or analyse a PDF's layout.

Tổng quan

Nhà phát hànhokou-ai
Kho mãokou-skills
Tên kỹ năngpdf-extract-template
Sao
81
Bản fork
19
Tệp đi kèm
7
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được okou-ai công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Pdf Extract Template trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/okou-ai/okou-skills/tree/main/extract-template/pdf
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/okou-ai/okou-skills.git /tmp/okou-skills
mkdir -p .claude/skills
cp -r /tmp/okou-skills/extract-template/pdf .claude/skills/pdf-extract-template
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Pdf Extract Template trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Pdf Extract Template ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Pdf Extract Template với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Extract a template package from a PDF

Input: one .pdf. Output: a loadable skill package whose instructions and resources match the selected reuse scope.

If the original .docx exists, use ../docx/SKILL.md instead. For slide PDFs, use ../presentation/SKILL.md unless the user requested a document template.

Run every command below from extract-template/pdf/.

Create page images to inspect the document's layout, typography and fillable areas, then choose the reuse scope. Keep the original for text and geometry. Reuse existing source captures; otherwise render once at the original page proportions:

bash
node ../scripts/render-document.mjs --input <source.pdf> --out source-render

Inspect the returned page images; the returned PDF is also available for reference. Use a new output directory for each render.

Choose the reuse scope

Read ../document-reuse.md, choose from representative rendered pages and the user's purpose, then use the matching section below. For style extraction, continue at Style extraction.

Slot filling

Copy the source to package/template.pdf. Write package/SKILL.md with the slot map and filling instructions from the shared guide. For each slot, record its page, meaning and filling format. Use an existing PDF form field's name where available; otherwise record the blank's rectangle and text appearance from the page.

Instruct the skill to fill a copy of template.pdf through its form fields or place text within the recorded blank areas. Keep the original page content and artwork intact; do not reconstruct the page or replace its fixed prose. Render the filled copy to verify the values fit and everything outside the slots remains unchanged. Continue at Publish the source package.

Structure and expression reuse

Copy the source to package/example.pdf. Write package/SKILL.md with the structure and writing rules from the shared guide, including source examples of the phrasing, tone and information order to reuse.

Record the layout of the blocks a new document needs, with their typography, spacing and repeat-or-omit rules. Extract reusable artwork into the package when needed. A PDF is a visual and writing example, not an editable paragraph tree: tell the skill how to compose new content into that layout using the example and packaged assets, allowing the recorded parts to grow or repeat. Identify any wording that stays fixed. Render the result and compare both its layout and expression with the example. Continue at Publish the source package.

Publish the source package

bash
node ../scripts/cover-page.mjs --input <the original .pdf> --out cover.png
bash
npx --yes --package="${CLI_PKG_URL}" okou user-template publish \
  --title "<user-visible template name>" \
  --kind document \
  --source <the original .pdf> \
  --cover cover.png \
  --page-count <pageCount from cover-page.mjs> \
  --package package

Keep the source copy in package/; --source supplies the catalog document and does not replace the files a later run needs. Publish without --cover and --page-count only when cover-page.mjs failed; report what it said. Say the template exists only after the command succeeds, then stop.

Style extraction

Prerequisites

bash
pip install pymupdf
python3 scripts/ensure_pandoc.py --dir ./vendor   # then run the export PATH line it prints

1. Analyse

bash
python3 scripts/analyze_pdf.py <source.pdf> --json styles.json

Read the report:

  • [structure tree] present → take the heading levels in step 3 from it.
  • "No text layer" → OCR the PDF first, then restart.
  • [body candidates] → the chosen group must be running prose. If its sample is a table header, an index or a caption, re-run with --body <rank>.

2. Declare the column count

Inspect the source page images. Re-run step 1 with --columns N.

3. Map the heading levels

Under [inferred styles], decide each group's role from its sample text and write the map:

--map 1=Heading1,2=Title,3=Heading2

Right side: Title, Subtitle, Heading1..Heading9 or skip. The largest group is usually the document title, not Heading1.

4. Settle the margins

Use the suggested row. Where measured disagrees with it by more than rounding, measure the page yourself and pass --top, --right or --left in cm. The bottom margin is never measured. Pass --bottom as:

  • the measured bound, when some page is full to the bottom;
  • for a Typst source with a footer, (page height − footer baseline − 0.73 × footer size) / 0.7, in cm;
  • otherwise the mirror of the top, which suggested already holds.

On a two-column document the two columns must come out the same width.

5. Build

bash
python3 scripts/build_reference.py styles.json reference.docx \
        --map 1=Heading1,2=Title,3=Heading2 [--bottom 2.2 ...]

--map keys are the # column of [inferred styles]. Map every group that is a heading; leave captions and footnotes unmapped.

6. Verify

bash
python3 scripts/verify_roundtrip.py reference.docx styles.json \
        --map 1=Heading1,2=Title,3=Heading2

Same --map as step 5. Exit code must be 0. NOT MEASURED is not a failure.

7. Package

bash
python3 scripts/make_package.py <source.pdf> reference.docx styles.json <out dir> \
        --map 1=Heading1,2=Title,3=Heading2 --body 2 [--bottom 2.2 ...]

Pass every flag used in steps 1–5. The output directory name is the skill name; --name overrides it. Add anything the scripts could not measure to the package's Limits.

Optional: adjust styles, add a header or footer

bash
python3 scripts/set_style.py reference.docx --list
python3 scripts/set_style.py reference.docx "Block Text" --size 10.5 --color 6C757D
python3 scripts/set_style.py reference.docx "Source Code" --create --font Consolas --size 9
python3 scripts/set_header_footer.py reference.docx --header "Company" --footer "Page " --page-number
python3 scripts/set_header_footer.py reference.docx --header 'Title\tv2.3'   # left / right

Then step 6 with --structure-only, then step 7.

8. Publish

bash
node ../scripts/cover-page.mjs --input <source.pdf> --out cover.png
bash
npx --yes --package="${CLI_PKG_URL}" okou user-template publish \
  --title "<user-visible template name>" \
  --kind document \
  --source <source.pdf> \
  --cover cover.png \
  --page-count <pageCount from cover-page.mjs> \
  --package <out dir>

Publish without --cover and --page-count only when cover-page.mjs failed; report what it said. Say the template exists only after the command succeeds.

Rules

  • Reproduce the source. Do not correct an inverted hierarchy or a style left at a default; the package records it.
  • Steps 2–4 are not recorded in the PDF. Settle each against the evidence the step names, never the script's default.
  • The running head and foot are rebuilt from [running head/foot]. If that line lists body text, the source has no header; run set_header_footer.py reference.docx --clear.
  • Change the column layout only when asked.

Troubleshooting

SymptomAction
Every heading level is off by oneRedo step 3 from the sample column
Right margin far too largeNo line fills the column; measure it off a page and pass --right
Single-page PDF gives bad marginsRunning heads cannot be detected; measure all four and pass them
Paragraph metrics implausible, or the body candidate is a tableRe-run step 1 with --body <rank>
Body text splits into several groupsReal difference in size, colour or weight; keep the largest, --map <n>=skip the rest
Space after reads NOT MEASUREDNo paragraph is followed by a paragraph; pandoc's default stays
Heading before/after look offset_style.py --before/--after, then step 6 with --structure-only
Verify fails after a deliberate changeRe-run step 6 with --structure-only
Heading gaps near zero on a multi-column source--columns was not passed; redo step 2
A header or footer added later sits a few points offStep 1 sets the distance from the font's hhea metrics; when it printed no hhea line, install the source's font and rerun, or pass set_header_footer.py --header-distance PT --footer-distance PT (page edge to the line box, baseline − 1.16 × size for Noto Sans CJK)
LibreOffice preview shows a smaller gap above a heading than the sourceExpected. LibreOffice takes the larger of space-after and space-before; Word adds them, and the template is written for Word
Title→Subtitle or Subtitle→Heading gap doubles in WordBoth sides carry the same gap (Word adds them, LibreOffice takes the larger). Zero one side: set_style.py reference.docx "Subtitle" --before 0
A paragraph repeated on every page is listed as a running headBody text in the header band. Pass the margins you measured; the styles are unaffected

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Pdf Extract Template làm được gì?

Extract a template skill from a PDF document for filling slots, reusing structure and expression, or applying its visual style. Use when asked to extract a PDF template or its styles, turn a PDF into a Word template, or analyse a PDF's layout.

Vì sao nên dùng Pdf Extract Template trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Pdf Extract Template là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Pdf Extract Template trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/okou-ai/okou-skills/tree/main/extract-template/pdf. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Pdf Extract Template?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Pdf Extract Template với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Pdf Extract Template với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Pdf Extract Template có miễn phí không?

Kỹ năng này được okou-ai phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇