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

auto-report

v1.0.2

Published

A wonderful Javascript library to make great reports.

Downloads

6

Readme


Table of contents

npm install auto-report --save

Import it to your code using:

const AutoReport = require("auto-report");

Examples

AutoReport use HTML with tags to generate the PDF. For the examples below We will use the following HTML.

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <div>
            <p>{{@report_name}}</p>
        </div>
        {{@table}}
    </body>
</html>

Example 1) Render a value:

const template = '<html>...'; // Template defined above. 
const AutoReport = require('auto-report');
const AutoReportPDF = new AutoReport.PDF();

AutoReportPDF.init(template);

AutoReportPDF.render('report_name', 'New Report Name');

AutoReportPDF.create('your-path/file.pdf').then(data => console.log(data)).catch(err => console.log(err));

Example 2) Render a table:

const template = '<html>...'; // Template defined above. 
const AutoReport = require('auto-report');
const AutoReportPDF = new AutoReport.PDF();

const columns = [{
    name: 'Name'
}, {
    name: 'Age'
}, {
    name: 'Country'
}];

const rows = [
    ['Mário', 12, 'BR'],
    ['Martin', 23, 'US'],
    ['Jacque', 22, 'FR']
];

AutoReportPDF.init(template);

AutoReportPDF.renderTable(columns, rows, {
    tag: 'table' //The tag that should be replaced.
});

AutoReportPDF.create('your-path/file.pdf').then(data => console.log(data)).catch(err => console.log(err));

or (the rows can be an array of objects):

const columns = [{
    name: 'Name'
}, {
    name: 'Age'
}, {
    name: 'Country'
}];

const rows = [{
    name: 'Mário',
    user_age: 12,
    country: 'BR'
}, {
    name: 'Martin',
    user_age: 23,
    country: 'US'
}, {
    name: 'Jacque',
    user_age: 22,
    country: 'FR'
}];

AutoReportPDF.init(template);

AutoReportPDF.renderTable(columns, rows, {
    tag: 'table', //The tag that should be replaced.,
    properties: ['name', 'user_age', 'country'] //Properties to access row object
});

AutoReportPDF.create('your-path/file.pdf').then(data => console.log(data)).catch(err => console.log(err));

More examples

Other examples will be created soon in addition to the complete documentation.

Contributing

You may contribute in several ways like creating new features, fixing bugs, improving documentation and examples or translating any document here to your language.

License

MIT