Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdf-report

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf-report

A node module that is capable of generating pdf reports from HTML templates.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

pdf-report

A node module that is capable of generating pdf reports from HTML templates.

Introduction

pdf-report was created out of the need to reliably generate PDF reports based off of templated information. There were many other tools out there that did similar jobs to this but had a poor code base; this tool aims to achieve a better code base and more support.

Getting started

To install pdf-report, simply run the following command in your terminal (from your project directory):

npm install pdf-report --save

Example Code

// external dependencies
const PDFReport = require('pdf-report');
const path = require('path');
const fs = require('fs');

// constants/variables
const html = fs.readFileSync(path.join(__dirname, 'template.html')).toString();
const fileName = path.join(__dirname, 'example.pdf');

// logic
report.toFile(fileName)
  .then(function(filePath) {
    console.log('open', filePath);
  })
  .catch(function(error) {
    console.log('error', error);
  });

API

Possible Options (when instantiating)

{
  height: '10.5in',
  width: '8in',
  orientation: 'portrait',
  quality: 75,
  timeout: 30000,
  assetsDirectory: null,
  header: {
    height: '26mm'
  },
  footer: {
    height: '18mm'
  }
}

Consuming the Generated Report

After the report has been generated, it can be accessed via one of the following methods:

  1. .toFile(pathToSave) - generates the report and saves it to disk at the specified path
  2. .toBuffer() - generates the report and returns the buffer
  3. .toStream() - generates the report and returns a read stream to the file
  • If you'd like to style the report, you must include a single <style> tag in your HTML.
  • If you'd like to put a header on every page, be sure to place a single <header> tag in your HTML.
  • If you'd like to put a footer on every page, be sure to place a single <footer> tag in your HTML.

Keywords

FAQs

Package last updated on 08 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc