New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-to-pdf-studio

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-to-pdf-studio

Converting HTML template to PDF files

  • 1.18.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

html-to-pdf-studio

Converting HTML template to PDF files

Codacy Badge npm npm LICENSE Dependabot Status

System Requirements

  • Node.js (version >= 10)

Installing

  • yarn add html-to-pdf-studio

Usage

Compiling a handlebars HTML template

const fs = require("fs");
const path = require("path");
const { compileHTML, createPDF } = require("html-to-pdf-studio");

const cssPath = path.join(__dirname, "./example/templates/style.css");
const css = fs.readFileSync(cssPath, "utf8");

const htmlPath = path.join(__dirname, "./example/templates/index.html");
const html = fs.readFileSync(htmlPath, "utf8");

let data = require("./example/templates/data.json");
const dataBinding = Object.assign(data, { css });

const compiledHTML = compileHTML(html, dataBinding);

Create PDF file from final HTML compiled with handlebars previously demonstrated

const path = require("path");
const { createPDF } = require("html-to-pdf-studio");

const fileName = "invoide.pdf";
const outputPath = path.join(__dirname, "./example/output");

if (!fs.existsSync(outputPath)) fs.mkdirSync(outputPath);

const pdfOptions = {
  format: "A4",
  headerTemplate: "<p></p>",
  footerTemplate: "<p></p>",
  displayHeaderFooter: false,
  margin: {
    top: "40px",
    bottom: "100px",
  },
  printBackground: true,
  path: path.join(outputPath, fileName),
};

(async () => {
  await createPDF(compiledHTML, pdfOptions);
})();

Inspiration

tranchuong - html_to_pdf

License

Copylefted (c) 2020 Henrique Carvalho da Cruz Licensed under the MIT license.

Keywords

FAQs

Package last updated on 12 May 2020

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