> ### Please, before reading this page, be sure to know what StrapDown.js is

> Check out index.html if you don't know yet how cool StrapDown.js is !

# StrapDown2PDF

StrapDown2PDF is a super cool Bash script designed to print a StrapDown-powered web-page to a PDF document.

## More details

To be more precise, StrapDown.js allows you to write pretty HTML pages with the Markdown syntax (more details here index.html).

And StrapDown2PDF can be used (on your laptop, from the command line) to transform the document from HTML (writen with Markdown) to PDF (with one intermediate phasis as a LaTeX file).

## Example and how-to

This page as a PDF is a pretty good example of an automatically compiled PDF file.

Warning: this script is still experimental: the compilation is never perfect. It is advisable to use the `-keep` option, change a little bit the LaTeX file and then compile again.

### How-to ?

You just have to use this command, in a terminal:

> `bash $ strapdown2pdf MyWebPage.html # This will produce "MyWebPage.pdf"`

### More than one file at a time ?

strapdown2pdf even supports multi arguments. For instance, the following command will print to PDF every StrapDown.js-flavored HTML file in the current directory:

> `bash $ echo "Calling 'strapdown2pdf *.html' will produce a PDF for every .html document in the current directory." $ strapdown2pdf *.html`

### Even more details?

strapdown2pdf comes with a basic help included ! Just ask with option `-h` (as always):

> ```bash $ strapdown2pdf -h strapdown2pdf -help | [options]

> Print a StrapDown-powered web-page to a PDF document, using lunamark and autotex.

> Help: -h to print this help message (and quit). -v to print just the version of strapdown2pdf (and quit).

> Options: -i|-interactive run PDFLaTeX with the interactive (errorstopmode) mode (default is batchmode). -q|-quiet run strapdown2pdf in quiet mode (no output at all, everything is redirected to /tmp/strapdown2pdf.log). -m|-htm run strapdown2pdf to produce a simple HTML file (which do not use StrapDown.js), written to a .htm file. For important document, producing a .htm autonomous file is a good idea. -d|-discrete run strapdown2pdf is discrete mode, without adding any creditentials in the produced document. -s[0-9][0-9]% change the default scale used by autotex (default is 85%, '-70%', '-75%' or '-80%' are good also) New! -[0-9][0-9]pt change the default police size used by autotex (default is 11pt, '-10pt' or '-12pt' are good also) New! -k|-keep keep the intermediate .tex file. New! -s|-sign sign the produce PDF document with GnuPG (thanks to PDFCompress).

> strapdown2pdf v0.8 : Copyrights: (c) Lilian Besson 2011-2014. Released under the term of the GPL v3 Licence (more details on http://perso.crans.org/besson/LICENSE.html). In particular, strapdown2pdf is provided WITHOUT ANY WARANTY. ```

### Options

strapdown2pdf now comes with these options:

- `-interactive` (shortcut is `-i`) to run PDFLaTeX with the interactive (errorstopmode) mode (default is batchmode),
- `-quiet` (shortcut is `-q`) to run strapdown2pdf in quiet mode (no output at all, everything is redirected to `/tmp/strapdown2pdf.log`),
- `-htm` (shortcut is `-m`) to produce a simple HTML file (which do not use StrapDown.js, see this example strapdown2pdf.htm), written to a .htm file. For important document, producing a .htm autonomous file is a good idea,
- `-discrete` (shortcut is `-d`) to run strapdown2pdf is discrete mode, without adding any creditentials in the produced document,
- `-s[0-9][0-9]*%` (e.g. `-79%`) to change the default scale used by autotex (default is 85%, '-70%', '-75%' or '-80%' are good also),
- `-[0-9][0-9]*pt` (e.g. `-10pt`) to change the default police size used by autotex (default is 11pt, '-10pt' or '-12pt' are good also),
- `-keep` (shortcut is `-k`) to keep the intermediate `.tex` file,
- `-sign` (shortcut is `-s`) to sign the produce PDF document with GnuPG (thanks to PDFCompress option `--sign`).

## Mandatory requirements

- lunamark (an awesome lua-powered Markdown to LaTeX processor),
- autotex (from my web page, or from bin/autotex).

## Optionnal requirements

These external scripts are not really mandatory, you could do without it by modifying a couple of lines of the script's code:

- PDFCompress (from my web page, or from bin/PDFCompress),
- pdflatex (from my web page, or from bin/pdflatex).

# Future features ?

### A 100% perfect support for embeded LaTeX code

These two examples (3 and 4) show how to include MathJax in a StrapDown-flavored HTML page to simply embed some LaTeX equations.

> Apparently, now strapdown2pdf have a better support for any (not too complicated) $\LaTeX{}$ code embedded in the Markdown source. Any feedback is welcome, and I will continue to improve this feature.

### Some examples of a good PDF printed version of a StrapDown.js powered page

> These are from September, October and November 2014.

- This (English) translation of a French press article about Mahindra École Centrale, nicely printed to this PDF,
- This (English) translation of another French press article about the future École Centrale Casablanca, nicely printed to a PDF, quickly modified by hand to include an image,
- This small (French) research report on a non-linear Partial Differential Equation, nicely printed to a PDF, with very good support of LaTeX (since this modification),
- This (French) homepage of a programming project on Euler theorems on Eulerian path. I did this as an assignement for my M.Sc. of Computer Science in 2014, and it was also a good training for one oral exam of the French national competitive examination to become a prep' school professor in Mathematics and Computer Science (for which I have been ranked 23rd among 795 in 2014!).

### Autocompile on the fly ?

Make a version "on the browser" ? Something like, if index.html uses StrapDown.js, then index.html?pdf can be the same HTML page, but using javascript (like texlive.js) to autoproduce a PDF version of the page in the background, asking to download it when it is done.

An example is there. It is so cool I want to use it :)

### Add a "Compile to PDF with TeXLive" button in StrapDown theme

I added a Squirt button to the two StrapDown.js theme, and therefore I guess it could be possible to do the same for a "Compile to PDF with TeXLive" button !

# About

### Hacked by Lilian Besson

### Languages

- GNU Bash v4+ for the script,
- Markdown and StrapDown.js for this page.

### License

This project is released under the GPLv3 license, for more details, take a look at the LICENSE file in the source.

Basically, that allow you to use all or part of the project for you own business.