PDF Generator
When to Use This Skill
Use this skill when:
- Creating PDF documents programmatically from data or specifications
- Filling PDF forms with dynamic data
- Adding watermarks, stamps, or overlays to existing PDFs
- Extracting text and metadata from PDF files
- Merging multiple PDFs into one document
- Analyzing PDF structure and form fields
Do NOT use this skill when:
- User wants to open/view PDFs (use native PDF viewer)
- Complex page layout with flowing text is needed (consider HTML-to-PDF tools)
- Working with password-protected PDFs (limited support)
- OCR is needed for scanned documents
Prerequisites
- Deno installed (https://deno.land/)
- Input PDF files for template-based operations
- JSON specification for scratch generation
Quick Start
Two Modes of Operation
-
Template Mode: Modify existing PDF templates
- Fill form fields (text, checkbox, dropdown)
- Add overlays (text, images, shapes)
- Merge and combine PDFs
-
Scratch Mode: Create PDFs from nothing using JSON specifications
Instructions
Mode 1: Template-Based Generation
Step 1a: Analyze the Template
Extract form fields and structure from an existing PDF:
Output (inventory.json):
Step 1b: Create Fill Specification
Create form-data.json:
Step 1c: Generate Filled PDF
Adding Overlays (Watermarks, Stamps)
Create watermark-spec.json:
Merging PDFs
Create merge-spec.json:
Mode 2: From-Scratch Generation
Step 2a: Create Specification
Create spec.json:
Step 2b: Generate PDF
Examples
Example 1: Fill Application Form
Scenario: Automatically fill a job application form.
Example 2: Add Approval Stamp
Scenario: Add an "APPROVED" stamp to a document.
stamp-spec.json:
Example 3: Create Report with Table
Scenario: Generate a simple report with a data table.
report-spec.json:
Script Reference
Element Types (Scratch Mode)
Available Fonts
Helvetica(default)HelveticaBoldHelveticaObliqueTimesRomanTimesBoldCourierCourierBold
Page Sizes
A4(595.28 x 841.89 points)Letter(612 x 792 points)Legal(612 x 1008 points)- Custom:
[width, height]in points
Common Issues and Solutions
Issue: Form fields not found
Symptoms: Error saying field name doesn't exist.
Solution:
- Run
analyze-template.tsto get exact field names - Field names are case-sensitive
- Some PDFs have non-fillable text that looks like form fields
Issue: Text positioning is off
Symptoms: Text appears in wrong location.
Solution:
- PDF coordinates start from bottom-left (0,0)
- Y increases upward, X increases rightward
- Use
analyze-template.tsto see page dimensions
Issue: Images not appearing
Symptoms: Image overlay not visible.
Solution:
- Check file path is relative to spec.json location
- Verify image is PNG or JPEG format
- Ensure coordinates are within page bounds
Issue: Merged PDF has wrong page order
Symptoms: Pages appear in unexpected order.
Solution:
prependPdfsadd pages before templateappendPdfsadd pages after template- Use
pagesarray to select specific pages:[1, 3, 5]
Limitations
- No built-in table layout: Tables require manual column width specification
- Standard fonts only: Custom font embedding not supported in scratch mode
- No flowing text: Text doesn't automatically wrap to next page
- Limited form field creation: Can fill existing forms, not create new fields
- No encryption: Cannot create password-protected PDFs
- Basic graphics: No gradients, patterns, or complex paths
- Text extraction: May not work perfectly on all PDFs (depends on PDF structure)
Related Skills
- pptx-generator: For creating PowerPoint presentations
- docx-generator: For creating Word documents
- xlsx-generator: For creating Excel spreadsheets

