Generate professional invoice PDFs with line items
✓Works with OpenClaudeYou are a PDF generation specialist. The user wants to generate professional invoice PDFs with line items, company details, and itemized pricing.
What to check first
- Install
pdfkitandbwip.js(barcode support):npm install pdfkit bwip.js - Verify Node.js version supports Buffer operations:
node --version(v14+) - Check that your invoice data structure includes: invoiceNumber, date, client details, line items with quantity/rate, and totals
Steps
- Import PDFKit and create a document stream writing to a file path
- Set up page dimensions (8.5×11 inches at 72 DPI for US Letter)
- Add header section with company logo/name, address, and contact info
- Insert invoice metadata (invoice number, date, due date) in top-right corner
- Create bill-to and ship-to sections with client details
- Build a table structure for line items with columns: description, quantity, unit price, amount
- Calculate and display subtotal, tax, and total amounts
- Add footer with payment terms, notes, and optional barcode
- Finalize and close the PDF stream
Code
const PDFDocument = require('pdfkit');
const fs = require('fs');
const bwip = require('bwip.js');
async function generateInvoicePDF(invoiceData, outputPath) {
const doc = new PDFDocument({ size: 'Letter', margin: 50 });
const stream = fs.createWriteStream(outputPath);
doc.pipe(stream);
// Header
doc.fontSize(24).font('Helvetica-Bold').text('INVOICE', 50, 50);
doc.fontSize(10).font('Helvetica').text('Acme Corp', 50, 90);
doc.text('123 Business St, Suite 100');
doc.text('New York, NY 10001');
doc.text('contact@acme.com | (555) 123-4567');
// Invoice metadata (right-aligned)
const metaX = 400;
doc.fontSize(10).font('Helvetica-Bold').text('Invoice #:', metaX, 50);
doc.font('Helvetica').text(invoiceData.invoiceNumber, metaX + 80, 50);
doc.font('Helvetica-Bold').text('Date:', metaX, 70);
doc.font('Helvetica').text(new Date(invoiceData.date).toLocaleDateString(), metaX + 80, 70);
doc.font('Helvetica-Bold').text('Due Date:', metaX, 90);
doc.font('Helvetica').text(new Date(invoiceData.dueDate).toLocaleDateString(), metaX + 80, 90);
// Bill To
doc.fontSize(11).
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related PDF Generation Skills
Other Claude Code skills in the same category — free to download.
PDF Generator
Generate PDFs from HTML or React components
Report PDF
Generate data report PDFs with charts and tables
PDF Viewer
Embed PDF viewer in web applications
PDF Form Filler
Programmatically fill PDF forms and templates
PDF Form Filler
Programmatically fill PDF form fields from data
PDF Watermarker
Add watermarks to PDFs (text, image, or stamp)
PDF Text Extraction
Extract text from PDFs (including scanned ones via OCR) for indexing or analysis
Want a PDF Generation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.