Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@chelmsfordbeer/html-pdf-node-core
Advanced tools
Convert any html content or html page to PDF within a AWS lambda
Pagination plugin for converts html or url to pdf
The goal fo this fork is to make use of pupeteer-core instead of pupeteer, also using chrome-aws-lambda in order to be able to upload this function inside a netlify/aws lambda
npm install @ChelmsfordBeer/html-pdf-node-core
To convert HTML
page to PDF
using generatePdf
method:
var html_to_pdf = require('@ChelmsfordBeer/html-pdf-node-core');
let options = { format: 'A4' };
// Example of options with args //
// let options = { format: 'A4', args: ['--no-sandbox', '--disable-setuid-sandbox'] };
let file = { content: "<h1>Welcome to html-pdf-node</h1>" };
// or //
let file = { url: "https://example.com" };
html_to_pdf.generatePdf(file, options).then(pdfBuffer => {
console.log("PDF Buffer:-", pdfBuffer);
});
Parameters
file
<Object> File object should have one of the following properties:
options
<Object> Options object should have the following properties:
args
<Array<string>> Additional arguments to pass to the browser instance. The list of Chromium flags can be found here. This options will overwrite the default arguments. The default arguments are ['--no-sandbox', '--disable-setuid-sandbox']
.path
<string> The file path to save the PDF to. If path
is a relative path, then it is resolved to current working directory. If no path is provided, the PDF won't be saved anywhere.scale
<number> Scale of the webpage rendering. Defaults to 1
. Scale amount must be between 0.1 and 2.displayHeaderFooter
<boolean> Display header and footer. Defaults to false
.headerTemplate
<string> HTML template to print the header. Should be valid HTML markup with following classes used to inject printing values into them:
date
formatted datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the documentfooterTemplate
<string> HTML template to print the footer. Should use the same format as the headerTemplate
.printBackground
<boolean> Print background graphics. Defaults to false
.landscape
<boolean> Paper orientation. Defaults to false
.pageRanges
<string> Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.format
<string> Paper format. If set, takes priority over width
or height
options. Defaults to 'Letter'.width
<string|number> Paper width, accepts values labeled with units.height
<string|number> Paper height, accepts values labeled with units.margin
<Object> Paper margins, defaults to none.
preferCSSPageSize
<boolean> Give any CSS @page
size declared in the page priority over what is declared in width
and height
or format
options. Defaults to false
, which will scale the content to fit the paper size.Return value
Promise which resolves with PDF buffer.
Parameters
files
<Array<Object>> File object should have one of the follwing properties:
options
<Object> Options object should have the following properties:
args
<Array<string>> Additional arguments to pass to the browser instance. The list of Chromium flags can be found here. This options will overwrite the default arguments. The default arguments are ['--no-sandbox', '--disable-setuid-sandbox']
.path
<string> The file path to save the PDF to. If path
is a relative path, then it is resolved to current working directory. If no path is provided, the PDF won't be saved anywhere.scale
<number> Scale of the webpage rendering. Defaults to 1
. Scale amount must be between 0.1 and 2.displayHeaderFooter
<boolean> Display header and footer. Defaults to false
.headerTemplate
<string> HTML template to print the header. Should be valid HTML markup with following classes used to inject printing values into them:
date
formatted datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the documentfooterTemplate
<string> HTML template to print the footer. Should use the same format as the headerTemplate
.printBackground
<boolean> Print background graphics. Defaults to false
.landscape
<boolean> Paper orientation. Defaults to false
.pageRanges
<string> Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.format
<string> Paper format. If set, takes priority over width
or height
options. Defaults to 'Letter'.width
<string|number> Paper width, accepts values labeled with units.height
<string|number> Paper height, accepts values labeled with units.margin
<Object> Paper margins, defaults to none.
preferCSSPageSize
<boolean> Give any CSS @page
size declared in the page priority over what is declared in width
and height
or format
options. Defaults to false
, which will scale the content to fit the paper size.Return value
Promise which resolves with array of object which contains file objects with PDF buffers.
Example:
let options = { format: 'A4' };
let file = [{ url: "https://example.com", name: 'example.pdf' }];
html_to_pdf.generatePdfs(file, options).then(output => {
console.log("PDF Buffer:-", output); // PDF Buffer:- [{url: "https://example.com", name: "example.pdf", buffer: <PDF buffer>}]
});
FAQs
Convert any html content or html page to PDF within a AWS lambda
We found that @chelmsfordbeer/html-pdf-node-core 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.