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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jade-reporting

v0.1.1

Published

Generates fully customizable PDF-reports from Jade templates and JSON Data

Downloads

4

Readme

Title Image

Jade Reporting Build Status

A easy-to-use and fully-customizable report generator for node.js. This library wraps wkhtmltppdf using node-wkhtmltopdf and PDFtk to generate good-looking PDF-reports from jade or HTML including your own stationery.

It can also be used as a simple HTML2PDF generator with background-PDF functionality.

Installation

via npm:

npm install jade-reporting

Dependencies

Please make sure you have the command-line versions of wkhtmltppdf and PDFtk server installed.

Examples

Generating a simple PDF from an HTML string:

var report = require("jade-reporting");

//report.generate(source string or file, output filename, report data, options, callback(error, filename))
report.generate("<h1>PDF from string</h1><p>This is a string</p>", "Jade Simple.pdf");

Generating a complex report from a jade template with letterhead:

PDF Icon Generated Report

Jade template:

link(rel="stylesheet" src="reportstyle.css")
.content
  h1 Great Report
  h2 First Sub-Headline
  p= name
  p= mail
  p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  h2 Second Sub-Headline
  p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  p &nbsp;
  h1 List of TV-Shows
  table
  thead
    th TV Show Name
    th Station
    th My Rating
  each showData, showName in tvshows
    tr
      td= showName
      td= showData.station
      td= showData.rating
  p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
  strong Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  img(src="https://assets-cdn.github.com/images/modules/logos_page/Octocat.png")

Routine:


var _data = {
  subject: "Just A Report",
  tvshows: {
    "Doctor Who": {
      station: "BBC",
      rating: "Geronimo!"
    },
    "Person of Interest": {
      station: "CBS",
      rating: "Great"
    },
    "The Mentalist": {
      station: "CBS",
      rating: "Great"
    },
    "The Simpsons": {
      station: "FOX",
      rating: "Great"
    },
    "Family Guy": {
      station: "FOX",
      rating: "Great"
    },
    "True Blood": {
      station: "HBO",
      rating: "Bad"
    },
    "Desperate Housewifes": {
      station: "ABC",
      rating: "Bad"
    }
  }
};

var _config = {
  metaData: {
    author: "Michael Müller",
    title: "Testreport"
  },
  letterhead: "test/letterhead.pdf",
  margin: {
    left: 20,
    top: 50,
    bottom: 50
  }
};

report.generate(path.join(__dirname, "complex.jade"), "Jade Complex with Letterhead.pdf", _data , function(error, pdf) {
  if (error) {
    console.log (error);
    return false;
  }
  console.log ("Report created: " + pdf)
});

Options

  • stylesheet Injecting additional CSS-propertys to the template
  • header HTML-formated header to display on each page of the report
  • footer HTML-formated footer to display on each page of the report
  • margin Margin of the generated PDF-pages
    • left
    • rigth
    • top
    • bottom
  • letterhead Adding a PDF document as background to the report using PDFtk's multibackground function. Applies each page of the letterhead PDF to the corresponding page of the report. If the report has more pages than the letterhead PDF, then the final letterhead page is repeated across these remaining pages in the report.
  • metaData Meta data for the generated PDF
    • creator
    • author
    • title
  • executables
    • wkhtmltopdf Command to execute wkhtmltopdf. Default: "wkhtmltopdf"
    • pdftk Command to execute PDFtk Server. Default: "pdftk"

License

MIT