Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
high performance access to `wkhtmltopdf` and `wkhtmltoimage` from node.js.
The goal of this module is to provide high performance access to wkhtmltopdf
and wkhtmltoimage
from node.js.
Those two tools are from wkhtmltopdf, a software package that
provides utilities for rendering HTML into various formats using the QT Webkit rendering engine.
This module is based on an MIT licensed module named node-wkhtmltopdf.
The latest and greatest version of this software is available through npm.
npm install wkhtmltox
HTML to PDF, JPG, PNG with custom path
// include the node module
var wkhtmltox = require("wkhtmltox");
// instantiate a new converter.
var converter = new wkhtmltox();
// Locations of the binaries can be specified, but this is
// only needed if the programs are located outside your PATH
converter.wkhtmltopdf = '/opt/local/bin/wkhtmltopdf';
converter.wkhtmltoimage = '/opt/local/bin/wkhtmltoimage';
// Convert to pdf.
// Function takes (inputStream, optionsObject), returns outputStream.
converter.pdf(fs.createReadStream('foo.html'), { pageSize: "letter" })
.pipe(fs.createWriteStream("foo.pdf"))
.on("finish", done);
// Convert to image.
// Function takes (inputStream, optionsObject), returns outputStream.
converter.image(fs.createReadStream('foo.html'), { format: "jpg" })
.pipe(fs.createWriteStream("foo.jpg"))
.on("finish", done);
converter.image(fs.createReadStream('foo.html'), { format: "png" })
.pipe(fs.createWriteStream("foo.png"))
.on("finish", done);
Simple HTML to PDF web service
Here's a simple web server that converts HTML to PDF. Options can be supplied as query parameters:
var url = require('url');
var http = require('http');
var wkhtmltox = require('wkhtmltox');
var converter = new wkhtmltox();
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/pdf'});
converter.pdf(req, url.parse(req.url, true).query).pipe(res);
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Access it with curl
curl -d @test.html -s "http://localhost:1337/?copies=2" -o test.pdf
FAQs
high performance access to `wkhtmltopdf` and `wkhtmltoimage` from node.js.
The npm package wkhtmltox receives a total of 0 weekly downloads. As such, wkhtmltox popularity was classified as not popular.
We found that wkhtmltox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.