
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
html-to-document-adapter-pdf
Advanced tools
PDF adapter for html-to-document-core — converts a DocumentElement tree into .pdf using the html2pdf.js library.
PDF adapter for the html-to-document core library.
# Install this adapter (This assumes you have already installed
html-to-document or html-to-document-core) :
npm install html-to-document-adapter-pdf
If you're using the wrapper package (
html-to-document
), you'll still need to install this adapter separately.
For documentation on the wrapper:
https://www.npmjs.com/package/html-to-document
import { init } from 'html-to-document';
import { PdfAdapter } from 'html-to-document-adapter-pdf';
const converter = init({
adapters: {
register: [{ format: 'pdf', adapter: PdfAdapter }],
defaultStyles: [
{
format: 'pdf',
styles: {
paragraph: { lineHeight: 1.5 },
heading: { fontSize: '18px', fontWeight: 'bold' },
},
},
],
styleMappings: [
{
format: 'pdf',
handlers: {
fontWeight: (v) => ({ bold: v === 'bold' }),
textAlign: (v) => ({ align: v }),
},
},
],
},
});
// Convert HTML string to PDF Blob or Buffer:
const htmlString = '<h1>Hello, PDF!</h1><p>This is a test.</p>';
const elements = await converter.parse(htmlString);
const pdfBlob = await converter.convert(elements, 'pdf');
// Use `pdfBlob` to download or save the file.
PdfAdapter
Adapter class implementing IDocumentConverter
for PDF.
new PdfAdapter(options: {
styleMapper: StyleMapper;
defaultStyles?: Record<string, any>;
});
styleMapper
: a StyleMapper
instance carrying style mappings.defaultStyles
: optional defaults for styling elements.convert(elements: DocumentElement[]): Promise<Buffer | Blob>
bun install
at the root.bun run build
.cd packages/adapters/pdf
bun run test
bun run lint
/ bun run format
.ISC
FAQs
PDF adapter for html-to-document-core — converts a DocumentElement tree into .pdf using the html2pdf.js library.
The npm package html-to-document-adapter-pdf receives a total of 73 weekly downloads. As such, html-to-document-adapter-pdf popularity was classified as not popular.
We found that html-to-document-adapter-pdf demonstrated a healthy version release cadence and project activity because the last version was released less than 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.