## Introduction
Generate outline for pdf files generated using mdbook-pdf

## Motivation
### `mdbook-pdf` is good, but...
In [example](./example), I create a simple book, and I use `mdbook-pdf` as renderer to export `pdf` with outline.
```bash
cd example/a_book
docker run --rm -v $PWD:/book hollowman6/mdbook-pdf
```
You can see the generated `pdf` in `./example/a_book/book/pdf-outline/output.pdf`.

Also, you can see the generated `HTML` in `./example/a_book/book/html`

### Different outline

The sidebar of `HTML` is like: [html_outline](./data/html_outline.png), which is what I want.

The outline of pdf is like: [pdf_outline](./data/pdf_outline.png), a little bit different with html. Every heading in markdown file is shown in the outline, without any order.

### The reason
The pdf outline is generated by [mdbook_pdf_outline](https://github.com/HollowMan6/mdbook-pdf/blob/main/mdbook_pdf_outline/mdbook_pdf_outline.py). It base on the `print.html` rendered by HTML engine, and the outline is generated by `HTML Headings`, not `SUMMARY.md`. Therefore, if there are any headings in your markdown file, they will appear in the outline.

## Quick Start
### Install
```bash
pip3 install mdbook_pdf_summary
```
### Run
#### 1. Generate pdf 
```bash
pushd example/a_book
docker run --rm -v $PWD:/book hollowman6/mdbook-pdf
popd
```
#### 2. Generate outline based on  `SUMMARY.md`
```bash
mdbook-pdf-summary --html_path ./example/a_book/book/html/print.html --pdf_path ./example/a_book/book/pdf/output.pdf      --summary_path ./example/a_book/src/SUMMARY.md --output_path ./output_with_outline.pdf 
```

Or, use docker image:
```bash
docker run --rm -v $PWD:/book cmq2525/mdbook_pdf_summary --entrypoint mdbook-pdf-summary
```

The above command will generate `output_with_outline.pdf` in your `$WORKDIR`, the outline is like: [summary_outline](./data/summary_outline.png), same as `SUMMARY.md`

