
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
jspdf-md-renderer
Advanced tools
A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.
A utility to render Markdown directly into formatted PDFs using jsPDF.
npm install jspdf-md-renderer
import { jsPDF } from 'jspdf'
import { MdTextRender } from 'jspdf-md-renderer'
const markdown = `
# Project Report
This report includes **formatted markdown** content.
- Item 1
- Item 2
`
const doc = new jsPDF({ unit: 'mm', format: 'a4', orientation: 'portrait' })
await MdTextRender(doc, markdown, {
cursor: { x: 10, y: 10 },
page: {
format: 'a4',
unit: 'mm',
orientation: 'portrait',
maxContentWidth: 190,
maxContentHeight: 277,
lineSpace: 1.5,
defaultLineHeightFactor: 1.2,
defaultFontSize: 12,
defaultTitleFontSize: 14,
topmargin: 10,
xpading: 10,
xmargin: 10,
indent: 10,
},
font: {
bold: { name: 'helvetica', style: 'bold' },
regular: { name: 'helvetica', style: 'normal' },
light: { name: 'helvetica', style: 'light' },
},
endCursorYHandler: (y) => {
console.log('Final Y:', y)
},
})
doc.save('report.pdf')
import { jsPDF } from 'jspdf'
import 'jspdf-autotable'
import { MdTextRender } from 'jspdf-md-renderer'
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspdf@latest/dist/jspdf.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspdf-autotable@latest/dist/jspdf.plugin.autotable.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspdf-md-renderer@latest/dist/index.umd.js"></script>
<script>
const { jsPDF } = window.jspdf;
const { MdTextRender } = window.JspdfMdRenderer;
</script>
# to ######){width,height,align} attributes)const options = {
heading: {
bold: true,
h1: 26,
h2: 22,
h3: 18,
bottomSpacing: 3,
},
list: {
bulletChar: '\u2022 ',
indentSize: 8,
itemSpacing: 0,
},
paragraph: {
bottomSpacing: 3,
color: '#111827',
},
blockquote: {
barColor: '#4A90D9',
barWidth: 2,
paddingLeft: 6,
backgroundColor: '#F8FAFC',
},
codeBlock: {
backgroundColor: '#F6F8FA',
borderColor: '#E1E4E8',
borderRadius: 3,
padding: 5,
showLanguageLabel: true,
textColor: '#111827',
},
spacing: {
afterHeading: 2,
afterParagraph: 4,
afterCodeBlock: 4,
afterBlockquote: 3,
afterImage: 2,
afterHR: 2,
betweenListItems: 0,
afterList: 3,
afterTable: 3,
},
header: {
text: 'My Report',
align: 'center',
color: '#6b7280',
fontSize: 9,
},
footer: {
showPageNumbers: true,
align: 'right',
},
}
Behavior notes:
heading.hN -> page.defaultTitleFontSizeheading.bold defaults to truespacing.betweenListItems > list.itemSpacingpage.maxContentWidth for consistent block layoutSecurity is disabled by default for backward compatibility.
const options = {
// ...other options
security: {
enabled: true,
violationMode: 'skip', // 'skip' | 'throw' | 'placeholder'
placeholderText: '[blocked]',
placeholderImageText: '[blocked image]',
// Link controls
allowedLinkProtocols: ['https:', 'http:', 'mailto:', 'tel:'],
disablePdfLinks: false,
// Image controls
allowRemoteImages: true,
allowedImageProtocols: ['https:', 'http:'],
allowedImageDomains: ['cdn.example.com'],
allowDataUrls: true,
allowSvgImages: true,
// SSRF controls
blockLocalhost: true,
blockPrivateIPs: true,
blockLinkLocalIPs: true,
blockMetadataIPs: true,
// Limits
maxMarkdownLength: 500000,
maxImageCount: 200,
maxImageSizeBytes: 10 * 1024 * 1024,
maxNestedDepth: 20,
renderTimeoutMs: 30000,
// Hooks
validateUrl: async (url, type) => true,
onSecurityViolation: (violation) => console.warn(violation),
},
}
https://...) -> full protocol/domain/IP checks//host/path) -> treated as external absolute URL/a, ./a, ?q=1, #id) -> allowed by default unless custom validator rejectsallowedImageDomains semantics:
undefined -> allow all domains[] -> deny all domainsmaxImageSizeBytes uses decoded bytes for data URLsSecurityViolationError is exported for throw-mode handlingBrowser caveat:
MdTextRenderMdTextParserSecurityViolationErrorvalidateOptionsRenderOption, RenderSecurityOptions, SecurityViolation, ViolationMode, and othersContributions are welcome. Please read CONTRIBUTING.md.
MIT. See LICENSE.
FAQs
A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.
The npm package jspdf-md-renderer receives a total of 925 weekly downloads. As such, jspdf-md-renderer popularity was classified as not popular.
We found that jspdf-md-renderer 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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.