npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svgreport

v2026.2.0

Published

SVG report generator - Flow CSV data into PDF-based SVG templates for printing

Downloads

110

Readme

SVG Report

npm

svgreport is a CLI and library for generating printable reports using SVG templates.

Overview

This tool enables the following workflow:

  1. Field staff submit forms created in Excel as PDF
  2. IT department converts PDF to SVG templates
  3. n8n or similar tools convert business data to CSV (metadata/detail data)
  4. Report engine flows data into SVG templates and outputs HTML
  5. Print from browser or save as PDF

Features

  • Declarative Templates: SVG elements referenced by id attributes, data binding defined in template.json
  • Pagination Support: Use different SVG templates for first page and subsequent pages
  • Variable Details: Automatic page splitting based on number of detail rows
  • Browser Printing: Generates optimized HTML, can be saved as PDF via print dialog
  • Type Safety: TypeScript implementation with JSON Schema input validation

Installation

pnpm install
pnpm build

Usage

Template Development Workflow

# 1. Convert PDF to SVG (auto-selects pdf2svg/inkscape)
svgreport convert agreed.pdf ./raw/

# 2. Normalize SVG (unify mm units, expand transforms, cleanup)
svgreport normalize ./raw/ ./normalized/ -s a4

# 3. Generate new template (create boilerplate)
svgreport generate invoice v3 -d ./templates

# 4. Inspect text elements and identify ID candidates
svgreport inspect-text ./templates/invoice/v3/page-1.svg

# 5. Define fields in template.json, then validate
svgreport validate ./templates/invoice/v3/

# 6. Generate preview (check with dummy data)
svgreport preview ./templates/invoice/v3/ -o ./preview -s realistic

Rendering (Production Data)

# Render single job
svgreport render job.zip

# Specify output directory
svgreport render job.zip -o ./reports

# Specify template directory
svgreport render job.zip -t ./templates

Creating Test Data

# Create test job zip (2 detail rows)
pnpx ts-node scripts/create-test-job.ts

# Multi-page test (12 detail rows)
pnpx ts-node scripts/create-test-job.ts items-multi.csv

File Structure

Job ZIP Structure

job.zip
├── manifest.json    # Job definition (schema, template, inputs)
├── meta.csv         # Metadata (key-value format)
└── items.csv        # Detail data (table format)

Template Structure

templates/invoice/v2/
├── template.json    # Template settings (pages, fields, tables)
├── page-1.svg       # First page SVG
└── page-follow.svg  # Subsequent pages SVG

Data Formats

meta.csv (KV Format)

key,value
customer.name,Sample Company Inc.
customer.address,123 Main St...
invoice_no,INV-0001
issue_date,2026-02-02
total_amount,123456

items.csv (Table Format)

name,price,qty
Product A,100,2
Product B,200,1

Architecture

src/
├── core/
│   ├── datasource.ts          # CSV parser (KV/Table)
│   ├── manifest.ts            # manifest.json validation/loading
│   ├── template.ts            # template.json validation/loading
│   ├── template-validator.ts  # Template validation (schema + SVG refs)
│   ├── template-generator.ts  # New template boilerplate generation
│   ├── formatter.ts           # Date/number/currency formatting
│   ├── paginator.ts           # Page splitting logic (pure function)
│   ├── svg-engine.ts          # SVG manipulation (@xmldom/xmldom + xpath)
│   ├── svg-normalizer.ts      # SVG normalization (mm units, transform, cleanup)
│   ├── text-inspector.ts      # Text element extraction/analysis
│   ├── pdf-converter.ts       # PDF→SVG conversion (pdf2svg/inkscape)
│   ├── renderer.ts            # Orchestrator
│   ├── preview-generator.ts   # Preview generation (dummy data)
│   ├── html-writer.ts         # HTML generation
│   └── zip-handler.ts         # ZIP loading
├── types/
│   └── index.ts               # Type definitions
├── cli.ts                     # CLI entry point
└── index.ts                   # Library exports

Available Commands

| Command | Description | Example | |---------|-------------|---------| | render | Render job ZIP | svgreport render job.zip | | convert | PDF→SVG conversion (auto fallback) | svgreport convert input.pdf ./output/ | | normalize | SVG normalization | svgreport normalize ./raw/ ./norm/ -s a4 | | validate | Template validation | svgreport validate ./templates/inv/v1/ | | preview | Preview generation | svgreport preview ./templates/inv/v1/ | | inspect-text | Text element analysis | svgreport inspect-text page-1.svg -j out.json | | generate | New template generation | svgreport generate invoice v1 -d ./templates |

Output Structure

out/
└── <job_id>/
    ├── index.html              # Print-ready HTML
    ├── pages/
    │   ├── page-001.svg       # Individual SVG
    │   └── page-002.svg
    └── debug/                  # Debug info
        ├── job.json
        ├── template.json
        └── render.json

License

MIT