# pdeffff

> Uses phantomjs to convert an html file or string into a pdf stream

Latest version **1.0.1** (published 2015-06-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install pdeffff
pnpm add pdeffff
yarn add pdeffff
bun add pdeffff
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-06-11 |
| First published | 2015-06-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nikolas LeBlanc |
| Maintainers | nikolasleblanc |
| Keywords | express, pdf, html, stream |

## Links

- npm: https://www.npmjs.com/package/pdeffff
- Repository: https://github.com/nikolasleblanc/pdeffff
- Issues: https://github.com/nikolasleblanc/pdeffff/issues
- npm.io page: https://npm.io/package/pdeffff

## Dependencies (3)

- [q](https://npm.io/package/q.md) ^1.4.1
- [phantom](https://npm.io/package/phantom.md) ^0.7.2
- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.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.1 (latest) — 2015-06-11
- 1.0.0 — 2015-06-11

## README

# pdeffff
## Converts html files and strings, as well as urls, into pdf streams

### Options

Takes viewportSize and paperSize options, in an options object.

```
var options = {
  viewportSize: {
    width: 2000, // default 1100
    height: 1000 // default 800
  },
  paperSize: { // default, undefined
    format: "Letter",
    orientation: "portrait",
    margin: "1cm"
  }
};
```

### Sample usage

```
var pdeffff = require("pdeffff");
var fs = require("fs");
var uuid = require('node-uuid');

var options = {
  viewportSize: {
    width: 1000,
    height: 800
  },
  paperSize: {
    format: "Letter",
    orientation: "portrait",
    margin: "1cm"
  }
};

pdeffff.fromURL("http://cnn.com", options)
  .then(function(stream){
    var filename = uuid.v1() + '.pdf';
    var writableStream = fs.createWriteStream(filename);
    stream.pipe(writableStream);
  });

pdeffff.fromString("<p>Hey!</p>", options)
  .then(function(stream){
    var filename = uuid.v1() + '.pdf';
    var writeableStream = fs.createWriteStream(filename);
    stream.pipe(writeableStream);
  });

pdeffff.fromFile([readableStream], options)
  .then(function(stream){
    var filename = uuid.v1() + '.pdf';
    var writeableStream = fs.createWriteStream(filename);
    stream.pipe(writeableStream);
  });
```

This can also be used in express, or any other server that deals in streams.

```
app.post('/url', function (req, res) {
  pdeffff.fromURL(req.body.url, options)
    .then(function(stream) {
      stream.pipe(res);
    });
});
```

### Notes

This takes awhile to run (about 10-15 seconds), there are setTimeout's everywhere. Will work at chipping away at them, but in due time.

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