# page-wrapping

> [![npm](https://img.shields.io/npm/v/page-wrapping.svg)](https://www.npmjs.com/package/page-wrapping) [![Travis](https://img.shields.io/travis/react-pdf/page-wrapping.svg)](https://travis-ci.org/react-pdf/page-wrapping)

Latest version **1.1.0** (published 2018-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install page-wrapping
pnpm add page-wrapping
yarn add page-wrapping
bun add page-wrapping
```

## 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.1.0 |
| Published | 2018-11-06 |
| First published | 2018-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Diego Muracciole |
| Maintainers | diegomura |

## Links

- npm: https://www.npmjs.com/package/page-wrapping
- npm.io page: https://npm.io/package/page-wrapping

## Recent versions

- 1.1.0 (latest) — 2018-11-06
- 1.0.2 — 2018-09-11
- 1.0.1 — 2018-09-08
- 1.0.0 — 2018-09-08

## README

# page-wrapping

[![npm](https://img.shields.io/npm/v/page-wrapping.svg)](https://www.npmjs.com/package/page-wrapping)
[![Travis](https://img.shields.io/travis/react-pdf/page-wrapping.svg)](https://travis-ci.org/react-pdf/page-wrapping)

Generic page wrapping algorithm proposal.

## How it works

```js
import wrapPage from 'page-wrapping'

// Create node instance.
// It can be whatever type of construction you want, but should always if support Node interface (see below).
const node = Node({ left: 20, top: 20, width: 100, height: 100 })

// Start page wrapping process.
// You should pass as first argument the page children (in this case only one node),
// and as second argument the page height used to wrap the elements.
await wrapPage([node], 40)

// [
//   { left: 20, top: 20, width: 100, height: 20 },
//   { left: 20, top: 0, width: 100, height: 40 },
//   { left: 20, top: 0, width: 100, height: 40 }
// ]
```

## Node interface

| Property         | Description                                           | Type        |
| ---------------- | ----------------------------------------------------- | ----------- |
| left             | Node x coordinate                                     | Number      |
| top              | Node y coordinate                                     | Number      |
| width            | Node width                                            | Number      |
| height           | Node height                                           | Number      |
| minPresenceAhead | Presence ahead of element to not to break             | Number      |
| wrap             | Whether a node should be able to split in two or more | Boolean     |
| break            | Whether a node should create a page break             | Boolean     |
| fixed            | Whether a node should repeat throughout all pages     | Boolean     |
| parent           | Node pointer to parent                                | Node        |
| children         | Children nodes                                        | Array<Node> |
| appendChild      | Add node as children                                  | Function    |
| remove           | Detach node from paren                                | Function    |
| clone            | Returns a copy of target node                         | Function    |
| nodeWillWrap     | Callback before element wrap. Can return promise      | Function    |
| onNodeSplit      | Callback after element is split in two                | Function    |
| isEmpty          | Returns if node is empty or not                       | Function    |

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