# jspdf-react

> Wrapper jsPDF for React

Latest version **1.0.11** (published 2019-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install jspdf-react
pnpm add jspdf-react
yarn add jspdf-react
bun add jspdf-react
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2019-07-17 |
| First published | 2018-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 2.8 MB |
| Known vulnerabilities | 0 (+15 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 34 |
| Author | apipemc |
| Maintainers | apipemc |
| Keywords | react, jspdf, jspdf-react, react-jspdf |

## Links

- npm: https://www.npmjs.com/package/jspdf-react
- Repository: https://github.com/apipemc/jspdf-react
- npm.io page: https://npm.io/package/jspdf-react

## Dependencies (2)

- [jspdf](https://npm.io/package/jspdf.md) ^1.5.3
- [jspdf-autotable](https://npm.io/package/jspdf-autotable.md) ^3.1.3

## 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

- 1.0.11 (latest) — 2019-07-17
- 1.0.10 — 2019-03-09
- 1.0.9 — 2018-10-21
- 1.0.8 — 2018-10-21
- 1.0.7 — 2018-10-21
- 1.0.6 — 2018-10-21
- 1.0.5 — 2018-10-21
- 1.0.4 — 2018-10-21
- 1.0.3 — 2018-10-21
- 1.0.2 — 2018-10-21
- 1.0.1 — 2018-10-21
- 1.0.0 — 2018-10-21

## README

# jspdf-react

>

[![NPM](https://img.shields.io/npm/v/jspdf-react.svg)](https://www.npmjs.com/package/jspdf-react) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save jspdf-react
```

## ⚠️Note: Use CSS-in-JS, Styled-Component or emotion.

If you want to convert an html in pdf, I recommend using the library.
[https://github.com/eKoopmans/html2pdf.js](https://github.com/eKoopmans/html2pdf.js)

## Usage

```jsx
import React, { Component } from 'react'

import PDF, { Text, AddPage, Line, Image, Table, Html } from 'jspdf-react'

import OctoCatImage from './OctoCatImage'

const styleH1 = {
  fontSize: '15px',
  textAlign: 'center',
  color: 'red'
};

const invisibleStyle = {
  display: 'none',
};

export default class App extends Component {
  render () {
    const properties = { header: 'Acme' }
    const head = [["ID", "Name", "Country"]]
    const body = [
        [1, "Shaw", "Tanzania"],
        [2, "Nelson", "Kazakhstan"],
        [3, "Garcia", "Madagascar"],
    ]
    return (
      <React.Fragment>
        <PDF
          properties={properties}
          preview={true}
        >
          <Text x={35} y={25} size={40}>Octonyan loves jsPDF</Text>
          <Image src={OctoCatImage} x={15} y={40} width={180} height={180} />
          <AddPage />
          <Table
            head={head}
            body={body}
          />
          <AddPage format='a6' orientation='l' />
          <Text x={10} y={10} color='red'>Sample</Text>
          <Line x1={20} y1={20} x2={60} y2={20}/>
          <AddPage />
          <Html sourceById='page' />
        </PDF>
        <div id="page" style={invisibleStyle}>
          <h1 style={styleH1}>Source Html</h1>
            <p>
              <strong>lorem ipsumLorem </strong>Ipsum is simply dummy text of the printing and
              typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever
              since the 1500s, when an unknown printer took a galley of type and scrambled it to
              make a type specimen book. It has survived not only five centuries, but also the
              leap into electronic typesetting, remaining essentially unchanged. It was popularised
              in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
              and more recently with desktop publishing software like Aldus PageMaker including
              versions of Lorem Ipsum.
            </p>
        </div>
      </React.Fragment>
    )
  }
}
```

## License

MIT © [apipemc](https://github.com/apipemc)

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