Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

document-generation-pdf

БесплатноЗапускает вложенные скриптыНе проверен

Generate, fill, and assemble PDF documents at scale. Handles legal forms, contracts, invoices, certificates. Supports form filling (pdf-lib), template…

curiositechот curiositech★ 283 звезды на GitHub27 установок в других каталогах

Об этом скилле

Document Generation & PDF Automation

Expert in generating, filling, and assembling PDF documents programmatically for legal, HR, and business workflows.

When to Use

✅ Use for:

  • Legal form automation (expungement, immigration, contracts)
  • Invoice/receipt generation at scale
  • Certificate creation (completion, participation, awards)
  • Contract assembly from templates
  • Government form filling (IRS, court filings)
  • Multi-document packet creation

❌ NOT for:

  • Simple PDF viewing (use browser or pdf.js)
  • Basic file conversion (use online tools)
  • OCR text extraction (use Tesseract.js or AWS Textract)
  • PDF editing by hand (use Adobe Acrobat)

Technology Selection

pdf-lib vs Puppeteer vs LaTeX

Feature pdf-lib Puppeteer LaTeX
Form filling ✅ Native ❌ Complex ❌ No
Template rendering ❌ No ✅ HTML/CSS ✅ Templates
Performance (1000 PDFs) 5s 60s 30s
File size Small Medium Small
Signature fields ✅ Yes ❌ No ❌ No
Best for Government forms Invoices, reports Academic papers

Timeline:

  • 2000s: LaTeX for academic documents
  • 2010: PDFKit (Node.js) for generation
  • 2017: Puppeteer for HTML → PDF
  • 2019: pdf-lib for pure JS form filling
  • 2024: pdf-lib is gold standard for forms

Decision tree:

Need to fill existing form? → pdf-lib
Need complex layouts? → Puppeteer (HTML/CSS)
Need academic formatting? → LaTeX
Need to merge PDFs? → pdf-lib
Need digital signatures? → pdf-lib + DocuSign API

Common Anti-Patterns

Anti-Pattern 1: Using Puppeteer for Simple Form Filling

Novice thinking: "I'll use Puppeteer for everything, it's versatile"

Problem: 12x slower, 10x more memory, can't preserve form fields.

Wrong approach:

// ❌ Puppeteer for simple form filling (SLOW!)
import puppeteer from 'puppeteer';

async function fillForm(data: FormData): Promise<Buffer> {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  // Load PDF in browser
  await page.goto(`file://${pdfPath}`);

  // Somehow fill form fields? (hacky)
  await page.evaluate((data) => {
    // Can't easily access PDF form fields from DOM
    // Would need to convert PDF → HTML first
  }, data);

  const pdf = await page.pdf();
  await browser.close();

  return pdf;
}

Why wrong:

  • Browser overhead (200MB+ RAM per instance)
  • Can't access native PDF form fields
  • Loses interactive form capabilities
  • 12x slower than pdf-lib

Correct approach:

// ✅ pdf-lib for form filling (FAST!)
import { PDFDocument } from 'pdf-lib';

async function fillForm(templatePath: string, data: FormData): Promise<Uint8Array> {
  // Load existing PDF form
  const existingPdfBytes = await fs.readFile(templatePath);
  const pdfDoc = await PDFDocument.load(existingPdfBytes);

  // Get form
  const form = pdfDoc.getForm();

  // Fill text fields
  form.getTextField('applicant_name').setText(data.name);
  form.getTextField('case_number').setText(data.caseNumber);
  form.getTextField('date_of_birth').setText(data.dob);

  // Fill checkboxes
  if (data.hasPriorConvictions) {
    form.getCheckBox('prior_convictions').check();
  }

  // Fill dropdowns
  form.getDropdown('state').select(data.state);

  // Flatten form (make non-editable)
  form.flatten();

  // Save
  return await pdfDoc.save();
}

Performance comparison (1000 PDFs):

  • Puppeteer: 60 seconds, 4GB RAM
  • pdf-lib: 5 seconds, 200MB RAM

Timeline context:

  • 2017: Puppeteer released, everyone used it for PDFs
  • 2019: pdf-lib released, proper form handling
  • 2024: pdf-lib is standard for government forms

Anti-Pattern 2: Not Flattening Forms

Problem: Users can edit filled forms, causing data inconsistencies.

Wrong approach:

// ❌ Don't flatten - form stays editable
const pdfDoc = await PDFDocument.load(existingPdfBytes);
const form = pdfDoc.getForm();

form.getTextField('name').setText('John Doe');

const pdfBytes = await pdfDoc.save();
// User can open PDF and change "John Doe" to anything!

Why wrong:

  • User can modify official documents
  • Data doesn't match database
  • Violates document integrity

Correct approach:

// ✅ Flatten form after filling
const pdfDoc = await PDFDocument.load(existingPdfBytes);
const form = pdfDoc.getForm();

form.getTextField('name').setText('John Doe');

// Flatten (convert fields to static text)
form.flatten();

const pdfBytes = await pdfDoc.save();
// User can't edit filled values ✅

When NOT to flatten:

  • Draft documents (user needs to review/edit)
  • Multi-step workflows (partial completion)
  • Templates for users to fill manually

Anti-Pattern 3: Generating PDFs from HTML Without Page Breaks

Novice thinking: "HTML → PDF is easy with Puppeteer"

Problem: Content splits mid-sentence across pages.

Wrong approach:

// ❌ No page break control
const html = `
Полный SKILL.md на GitHub

Установить document-generation-pdf в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Edit
Bash(npm:*,latex*)

Вложенные файлы

.claude-plugin/plugin.jsonreferences/document-assembly.mdreferences/pdf-lib-guide.mdreferences/puppeteer-templates.mdscripts/document_assembler.tsscripts/form_filler.ts

FAQ

Что делает скилл document-generation-pdf?

Generate, fill, and assemble PDF documents at scale. Handles legal forms, contracts, invoices, certificates. Supports form filling (pdf-lib), template rendering (Puppeteer, LaTeX), digital signatures (DocuSign), and document assembly. Use for legal tech, HR automation, invoice generation. Activate on "PDF generation", "form filling", "document automation", "digital signatures". NOT for simple PDF viewing, basic file conversion, or OCR text extraction.

Как установить скилл document-generation-pdf?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл document-generation-pdf запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить document-generation-pdf с