# md-to-pdfmake

> Parser of markdown text to pdfmake object

Latest version **0.3.2** (published 2024-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install md-to-pdfmake
pnpm add md-to-pdfmake
yarn add md-to-pdfmake
bun add md-to-pdfmake
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2024-08-23 |
| First published | 2022-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 53.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 8 |
| Author | brunobarretofreitas |
| Maintainers | brunobfreitas |
| Keywords | markdown, pdfmake |

## Links

- npm: https://www.npmjs.com/package/md-to-pdfmake
- Repository: github.com:brunobarretofreitas/md-to-pdfmake
- Homepage: https://github.com/brunobarretofreitas/md-to-pdfmake
- Issues: https://github.com/brunobarretofreitas/md-to-pdfmake/issues
- npm.io page: https://npm.io/package/md-to-pdfmake

## Dependencies (2)

- [jsdom](https://npm.io/package/jsdom.md) ^19.0.0
- [marked](https://npm.io/package/marked.md) ^2.1.0

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2024-08-23
- 0.3.1 — 2024-08-23
- 0.2.1 — 2022-06-08
- 0.2.0 — 2022-06-08
- 0.1.1 — 2022-06-07

## README

# md-to-pdfmake

[![Build Status](https://app.travis-ci.com/brunobarretofreitas/md-to-pdfmake.svg?branch=master)](https://app.travis-ci.com/brunobarretofreitas/md-to-pdfmake)
[![npm version](https://img.shields.io/npm/v/md-to-pdfmake)](https://www.npmjs.com/package/md-to-pdfmake)

Parser of markdown text to [pdfmake](https://github.com/bpampuch/pdfmake) object.

## Installation

---

Using npm:

```shell
$ npm install md-to-pdfmake
```

## Example:

---

#### Mardown Text

```markdown
Hello World !

**That's a bold text**
**_That's a italic text_**

# That's a big text !

- Item 1
- Item 2
```

#### Parsed pdfmake object

```javascript
[
  { text: 'Hello World' },
  { text: [{ text: "That's a bold text", bold: true }] },
  { text: [{ text: "That's a italic text", italics: true }] },
  { text: "That's a big text" },
  {
    ul: [{ text: 'Item 1' }, { text: 'Item 2' }],
  },
];
```

## API

---

To parse a markdown string to pdfmake object is simple:

```typescript
import { toPdfMakeObject } from 'md-to-pdfmake';

const markdownText = '**Hello World**';
const parsedObject = toPdfMakeObject(markdownText);
```

You can also define the optional style properties provided by pdfmake for each parsed element:

| **Element**           | **Available Properties**                       |
| --------------------- | ---------------------------------------------- |
| **a**                 | fontSize, lineHeight, characterSpacing, margin |
| **p**                 | fontSize, lineHeight, characterSpacing, margin |
| **h1,h2,h3,h4,h5,h6** | fontSize, lineHeight, characterSpacing, margin |
| **li**                | fontSize, lineHeight, characterSpacing, margin |
| **ul**                | type, markerColor                              |
| **ol**                | type, markerColor, separator, reversed, start  |

Example using style properties:

```typescript
import { toPdfMakeObject } from 'md-to-pdfmake';

const markdownText = '# Hello World\n## Welcome'; // h1 and h2
const parsedObject = toPdfMakeObject(markdownText, {
  h1: { fontSize: 20 },
  h2: { fontSize: 18 },
});
```

## Supported elements
- Anchor
- Paragraph
- Ordered List
- Unordered List
- Headings (h1, h2, h3, h4, h5, h6)
- Strong
- Italic

---
_Source: https://npm.io/package/md-to-pdfmake · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
