<commit_before>---
layout: docs
title:  Documentation
shortTitle: Docs
permalink: /docs/
order: 2
inBook: true
---

## Setup

Use `Bindery.makeBook({ options })` to create a book and display it
immediately on page load. It takes an object of options as described below.

```js
// With required options
Bindery.makeBook({
  content: '#content',
});
```

### content

If the content is on the same page, use a CSS selector or a reference to the node. If the content must be fetched from a remote page, pass an object in the form of `{ url: String, selector: String }`.

```js
// CSS selector
Bindery.makeBook({
  content: '#content',
});

// Element
const el = document.getElementByID('content');
Bindery.makeBook({
  content: el,
});

// Fetch from a URL
Bindery.makeBook({
  content: {
    selector: '#content',
    url: '/posts.html',
  }
});
```

### pageSetup

- `size:` Book size, in the form of `{ width: String, height: String }`. Values must include absolute CSS units.
- `margin:` Book margin, in the form of `{ top: String, outer: String, bottom: String, inner: String }`. Values must include absolute CSS units.
- `bleed:` Amount of bleed. Values must include absolute CSS units. This affects the size of [full-bleed pages](#fullbleedpage)
and [spreads](#fullbleedspread), and sets the position of bleed and
crop marks.

```js
Bindery.makeBook({
  content: '#content',
  pageSetup: {
    size: { width: '4in', height: '6in' },
    margin: { top: '12pt', inner: '12pt', outer: '16pt', bottom: '20pt' },
    bleed: '12pt',
  },
});
```

### printSetup

Note that setting the paper size through bindery [only works in Chrome and Opera](https://caniuse.com/#feat=css-paged-media) as of 2017. Users with other browsers must set the size in the system print dialog.

- `layout:`
  - `Bindery.Layout.PAGES` One page per sheet, in numerical order `default`
  - `Bindery.Layout.SPREADS` Two pages per sheet, in numerical order
  - `Bindery.Layout.BOOKLET` Two pages per sheet, in booklet order. For printing double
  sided and folding into a saddle stitched booklet.
- `paper:`
  - `Bindery.Paper.AUTO` Sets paper to the size of the page or, if the layout is
   `spreads` or `booklet`, twice as wide as the page.
   Note that marks will not be visible. `default`
  - `Bindery.Paper.AUTO_BLEED` The size of the page plus the size of the bleed.
  Note that marks will not be visible.
  - `Bindery.Paper.AUTO_MARKS` The size of the page plus room for crop and bleed marks.
  - `Bindery.Paper.LETTER_PORTRAIT`
  - `Bindery.Paper.LETTER_LANDSCAPE`
  - `Bindery.Paper.A4_PORTRAIT`
  - `Bindery.Paper.A4_LANDSCAPE`
- `marks:`
  - `Bindery.Marks.NONE`
  - `Bindery.Marks.CROP` Note that crop marks are always outset by the bleed amount.`default`
  - `Bindery.Marks.BLEED`
  - `Bindery.Marks.BOTH`

```js
Bindery.makeBook({
  content: '#content',
  printSetup: {
    layout: Bindery.Layout.BOOKLET,
    paper: Bindery.Paper.AUTO_BLEED,
    marks: Bindery.Marks.CROP,
  },
});
```

## Preview

- `view:`
  - `Bindery.View.PREVIEW` shows the spreads of the book as they will appear when
  the book is trimmed and bound. If you choose this mode, Bindery will switch to `PRINT`
  before printing. `default`
  - `Bindery.View.PRINT` shows the complete printed sheet, which may include multiple pages,
  marks, and bleed if those options are enabled.
  Note that when printing a booklet, pages will appear out of order.
  - `Bindery.View.FLIPBOOK` shows a three-dimensional preview, making it easy
to visualize which pages will end up on the backs of others. If you choose this mode,
Bindery will switch to `PRINT` before printing.



```js
Bindery.makeBook({
  content: '#content',
  view: Bindery.View.FLIPBOOK,
})
```

### Controls

If you are frequently switching between views or print options,
you can install `bindery-controls` to create a UI to configure without
reloading. Just include the controls script before calling `makeBook`;

```html
<script src="https://unpkg.com/bindery@2.2.2"></script>
<script src="https://unpkg.com/bindery-controls"></script>

<script>
  Bindery.makeBook({ content: '#content' })
</script>
```<commit_msg>remove version num from docs<commit_after>---
layout: docs
title:  Documentation
shortTitle: Docs
permalink: /docs/
order: 2
inBook: true
---

## Setup

Use `Bindery.makeBook({ options })` to create a book and display it
immediately on page load. It takes an object of options as described below.

```js
// With required options
Bindery.makeBook({
  content: '#content',
});
```

### content

If the content is on the same page, use a CSS selector or a reference to the node. If the content must be fetched from a remote page, pass an object in the form of `{ url: String, selector: String }`.

```js
// CSS selector
Bindery.makeBook({
  content: '#content',
});

// Element
const el = document.getElementByID('content');
Bindery.makeBook({
  content: el,
});

// Fetch from a URL
Bindery.makeBook({
  content: {
    selector: '#content',
    url: '/posts.html',
  }
});
```

### pageSetup

- `size:` Book size, in the form of `{ width: String, height: String }`. Values must include absolute CSS units.
- `margin:` Book margin, in the form of `{ top: String, outer: String, bottom: String, inner: String }`. Values must include absolute CSS units.
- `bleed:` Amount of bleed. Values must include absolute CSS units. This affects the size of [full-bleed pages](#fullbleedpage)
and [spreads](#fullbleedspread), and sets the position of bleed and
crop marks.

```js
Bindery.makeBook({
  content: '#content',
  pageSetup: {
    size: { width: '4in', height: '6in' },
    margin: { top: '12pt', inner: '12pt', outer: '16pt', bottom: '20pt' },
    bleed: '12pt',
  },
});
```

### printSetup

Note that setting the paper size through bindery [only works in Chrome and Opera](https://caniuse.com/#feat=css-paged-media) as of 2017. Users with other browsers must set the size in the system print dialog.

- `layout:`
  - `Bindery.Layout.PAGES` One page per sheet, in numerical order `default`
  - `Bindery.Layout.SPREADS` Two pages per sheet, in numerical order
  - `Bindery.Layout.BOOKLET` Two pages per sheet, in booklet order. For printing double
  sided and folding into a saddle stitched booklet.
- `paper:`
  - `Bindery.Paper.AUTO` Sets paper to the size of the page or, if the layout is
   `spreads` or `booklet`, twice as wide as the page.
   Note that marks will not be visible. `default`
  - `Bindery.Paper.AUTO_BLEED` The size of the page plus the size of the bleed.
  Note that marks will not be visible.
  - `Bindery.Paper.AUTO_MARKS` The size of the page plus room for crop and bleed marks.
  - `Bindery.Paper.LETTER_PORTRAIT`
  - `Bindery.Paper.LETTER_LANDSCAPE`
  - `Bindery.Paper.A4_PORTRAIT`
  - `Bindery.Paper.A4_LANDSCAPE`
- `marks:`
  - `Bindery.Marks.NONE`
  - `Bindery.Marks.CROP` Note that crop marks are always outset by the bleed amount.`default`
  - `Bindery.Marks.BLEED`
  - `Bindery.Marks.BOTH`

```js
Bindery.makeBook({
  content: '#content',
  printSetup: {
    layout: Bindery.Layout.BOOKLET,
    paper: Bindery.Paper.AUTO_BLEED,
    marks: Bindery.Marks.CROP,
  },
});
```

## Preview

- `view:`
  - `Bindery.View.PREVIEW` shows the spreads of the book as they will appear when
  the book is trimmed and bound. If you choose this mode, Bindery will switch to `PRINT`
  before printing. `default`
  - `Bindery.View.PRINT` shows the complete printed sheet, which may include multiple pages,
  marks, and bleed if those options are enabled.
  Note that when printing a booklet, pages will appear out of order.
  - `Bindery.View.FLIPBOOK` shows a three-dimensional preview, making it easy
to visualize which pages will end up on the backs of others. If you choose this mode,
Bindery will switch to `PRINT` before printing.



```js
Bindery.makeBook({
  content: '#content',
  view: Bindery.View.FLIPBOOK,
})
```

### Controls

If you are frequently switching between views or print options,
you can install `bindery-controls` to create a UI to configure without
reloading. Just include the controls script before calling `makeBook`;

```html
<script src="https://unpkg.com/bindery"></script>
<script src="https://unpkg.com/bindery-controls"></script>

<script>
  Bindery.makeBook({ content: '#content' })
</script>
```
{'fraction_non_alphanumeric': 0.12199250392939186, 'fraction_numerical': 0.0049570789505501145, 'mean_word_length': 3.8630217519106407, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6363012', 'n_tokens_mistral': 2734, 'n_tokens_neox': 2668, 'n_words': 1006}