Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
express-hogan-pdf
Advanced tools
PDF generation using Hogan.js to template XML. Can be used as an express view engine or can output to a PDF stream, buffer, or file
PDF generation using Hogan.js to template XML. Can be used as an express view engine or can output to a PDF stream, buffer, or file
app.engine('pdfxml', require('express-hogan-pdf').engine);
app.get('/download-pdf', (req, res, next) => {
res.attachment('filename.pdf');
res.render('template.pdfxml', { title: 'Hello World' });
});
const pdf = require('express-hogan-pdf');
pdf.fileToStream(filePath, locals, (err, stream) => {});
pdf.fileToBuffer(filePath, locals, (err, buffer) => {});
pdf.fileToFile(filePath, locals, destFile, (err) => {});
app.get('/download-pdf', (req, res, next) => {
res.render('template.pdfxml',
{ title: 'Hello World', stream: true },
(err, stream) => {
if (err) return next(err);
res.attachment(stream.filename);
stream.pipe(res);
});
});
<pdf>
<config>
<filename>my-file.pdf</filename>
<document size="A4" marginBottom="50">
<title>{{title}}</title>
<colors darkred="#800"/>
<styles>
</styles>
</config>
<page>
<h1>{{title}}</h1>
<h2>Page 1</h2>
<indent>
<p>Indented text</p>
</indent>
<hr thickness="6"/>
<row>
<column width="33%">Column 1</column>
<column width="66%">Column 2</column>
</row>
<div>
A link to <a>example.com</a>
</div>
</page>
<page>
<h1 top="33%" left="100">Page 2</h1>
</page>
</pdf>
The XML format wraps most of PDFKit's available options.
The document must be wrapped in tags
paddingLeft
and show a left bar of thickness
and color
href
is specified an href is created by adding https://
to the beginning of the textFAQs
PDF generation using Hogan.js to template XML. Can be used as an express view engine or can output to a PDF stream, buffer, or file
We found that express-hogan-pdf 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.