
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
hmpo-xml-to-pdf
Advanced tools
PDF generation using an XML source. Can generate a file, buffer or stream.
const pdf = require('express-hogan-pdf');
pdf.toStream(xml, basePath, (err, stream) => {});
pdf.toBuffer(xml, basePath, (err, buffer) => {});
pdf.toFile(xml, basePath, destFile, (err) => {});
app.get('/path', (req, res, next) => {
let xml = '<pdf>xmldata</pdf>';
pdf.toStream(xml, '/base/path/for/images', (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 <pdf></pdf> tags
<config> Configuration section:
<document> PDFKit document options, eg: <document size="A4"/><title> Set document title<meta> Set PDF meta details such as <author>, <subject>, or <keywords><colors> Color aliases, eg <colors darkred="#880000"/><fonts> Font aliases, eg <fonts comic="Comic Sans Regular"/><filename> Set document filename<styles> Add or change page tag style definintions, eg: <styles><redtext extends="span" color="red"/></styles>
extends="String" Style definition to extenddisplay="String" Can be block or inlinemarginLeft="Number" Margin leftmarginRight="Number" Margin rightpaddingLeft="Number" Padding leftpaddingRight="Number" Padding rightcolor="String" Text color or aliasfont="String" Font alias, name or pathsize="Number" Font sizeunderline="Boolean" Underline textstrike="Boolean" Strikethrough textlineGap="Number" Line gap between wrapped linesparagraphGap="Number" Gaps between paragraphsalign="String" text alignmentpre="Boolean" Respect exact whitespace in tagstrim="Boolean" Trim whitespace at start of each linemarginTop="Number" Margin topmarginBottom="Number" Margin bottompaddingTop="Number" Padding toppaddingBottom="Number" Padding bottomwidth="Number" Width as an absolute or as a percentage of the parent blockheight="Number" Height as an absolute or as a percentage of the page height within the page marginsbackgroundColor="String" Background color or color alias. Background will only be filled if both a height and width are givenborder="Number" Border width. A border will only be drawn if both a height and width are givenborderColor="String" Border color or color alias<page> A page to render. Can take any PDFKit page options, such as page
<div><p><span><strong><small><indent> Indent text by paddingLeft and show a left bar of thickness and color
thickness="Number" Width of indent barcolor="String" Color or color alias of indent bar<hr> Horizontal rule divider line
thickness="Number" Height of divider linecolor="String" Color or color alias of divider line<row> A container for a set of columns<column> A left-aligned column within a row. Columns wrap within the row if the next column can't fit within the row's width<img> Draw an image
src="String" Source of the image to draw relative to the template filescale="Number" Size of image relative to its originalfit="Boolean" Fit image within the width and height without chaning its aspect ratioalt="String" Add alt text to an image to improve accessibility<a> Create a web link for the contained text.
href="String" The link to go to when clicked. If no href is specified an href is created by adding https:// to the beginning of the textOld repo for this service can be found here: https://github.com/HMPO/xml-to-pdf
FAQs
PDF generation from XML to a stream, buffer, or file
We found that hmpo-xml-to-pdf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.