Skip to content

Commit

Permalink
added more detail about the pdf generation process and also updated t…
Browse files Browse the repository at this point in the history
…he pdfs
  • Loading branch information
amzn-tomjoht committed Dec 29, 2017
1 parent 4b4666e commit 744754a
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 144 deletions.
4 changes: 0 additions & 4 deletions _data/sidebars/mydoc_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ entries:
url: /mydoc_push_build_to_server.html
output: web, pdf

- title: Getting around the password prompts in SCP
url: /mydoc_no_password_prompts_scp.html
output: web, pdf

- title: Publishing on Github Pages
url: /mydoc_publishing_github_pages.html
output: web, pdf
Expand Down
2 changes: 2 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ permalink: index.html
summary: These brief instructions will help you get started quickly with the theme. The other topics in this help provide additional information and detail about working with other aspects of this theme and Jekyll.
---

{% include note.html content="If you'd like to keep up on best practices for documentation, see my <a alt='technical writing blog' href='http://idratherbewriting.com'>technical writing blog: I'd Rather Be Writing</a>." %}

## Build the Theme

Follow these instructions to build the theme.
Expand Down
55 changes: 48 additions & 7 deletions pages/mydoc/mydoc_generating_pdfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,59 @@ folder: mydoc


## PDF overview
This process for creating a PDF relies on Prince XML to transform the HTML content into PDF. Prince costs about $500 per license. That might seem like a lot, but if you're creating a PDF, you're probably working for a company that sells a product, so you likely have access to some resources.
This process for creating a PDF relies on Prince XML to transform the HTML content into PDF. Prince costs about $500 per license. That might seem like a lot, but if you're creating a PDF, you're probably working for a company that sells a product, so you likely have access to some resources. There's also a free license that prints a small "P" watermark on your title page, so if you're fine with that, great.

The basic approach is to generate a list of all pages that need to be added to the PDF, and then add leverage Prince to package them up into a PDF.

It may seem like the setup is somewhat cumbersome, but it doesn't take long. Once you set it up, building a pdf is just a matter of running a couple of commands.

Also, creating a PDF this way gives you a lot more control and customization capabilities than with other methods for creating PDFs. If you know CSS, you can entirely customize the output.
The basic approach is to generate a list of all web pages that need to be added to the PDF, and then add leverage Prince to package them up into a PDF. Once you set it up, building a pdf is just a matter of running a couple of commands. Also, creating a PDF this way gives you a lot more control and customization capabilities than with other methods for creating PDFs. If you know CSS, you can entirely customize the output.

## Demo

You can see an example of the finished product here:

<a target="\_blank" class="noCrossRef" href="{{ "pdf/mydoc.pdf"}}"><button type="button" class="btn btn-default" aria-label="Left Align"><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> PDF Download</button></a>

To generate the PDF, browse to the theme's directory in your terminal and run this script:

```bash
. pdf-mydoc.sh
```

This builds a PDF for the documentation in the theme. Look in the **pdf** folder for the output, and see the "last generated date" to confirm that you generated the PDF.

To build a PDF for the other sample projects, run these commands:

```bash
. pdf-product1.sh
```

or

```bash
. pdf-product2.sh
```

You can see the details of the script in these files in the theme's root directory. For example, open pdf-mydoc.sh. It contains the following:

```bash
# Note that .sh scripts work only on Mac. If you're on Windows, install Git Bash and use that as your client.

echo 'Kill all Jekyll instances'
kill -9 $(ps aux | grep '[j]ekyll' | awk '{print $2}')
clear

echo "Building PDF-friendly HTML site for Mydoc ...";
bundle exec jekyll serve --detach --config _config.yml,pdfconfigs/config_mydoc_pdf.yml;
echo "done";

echo "Building the PDF ...";
prince --javascript --input-list=_site/pdfconfigs/prince-list.txt -o pdf/mydoc.pdf;

echo "Done. Look in the pdf directory to see if it printed successfully."
```

After stopping all Jekyll instances, we build Jekyll using a special configuration file that specifies a unique stylesheet. The build contains a file (prince-list.txt) that contains a list of all pages to be included in the PDF. We feed this list into a Prince command to build the PDF.

The following sections explain more about the setup.

## 1. Set up Prince

Download and install [Prince](http://www.princexml.com/doc/installing/).
Expand Down Expand Up @@ -66,6 +105,8 @@ Also note that there's a `output: pdf` property in case you want to make some of

In the configuration file, customize the values for the `print_title` and `print_subtitle` that you want. These will appear on the title page of the PDF.

We will access this configure file in the PDF generation script.

## 3. Make sure your sidebar data file has titlepage.html and tocpage.html entries

There are two template pages in the root directory that are critical to the PDF:
Expand Down Expand Up @@ -292,7 +333,7 @@ Because the theme uses JavaScript in the CSS, you have to add the `--javascript`

## 5. Customize and run the PDF script

Duplicate the pdf-mydocf.sh file in the root directory and customize it for your specific configuration files.
Duplicate the pdf-mydoc.sh file in the root directory and customize it for your specific configuration files.

```
echo 'Killing all Jekyll instances'
Expand Down
17 changes: 17 additions & 0 deletions pages/mydoc/mydoc_icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ folder: mydoc
## Font icon options
The theme has two font icon sets integrated: Font Awesome and Glyphicons Halflings. The latter is part of Bootstrap, while the former is independent. Font icons allow you to insert icons drawn as vectors from a CDN (so you don't have any local images on your own site).

## External icons

When you link to an external site, like [Jekyll](http://jekyllrb.com), an icon appears after the link. If you want to remove this icon, comment out this style in css/customstyles.css.

```css
/* this part adds an icon after external links, using FontAwesome*/
a[href^="http://"]:after, a[href^="https://"]:after {
content: "\f08e";
font-family: FontAwesome;
font-weight: normal;
font-style: normal;
display: inline-block;
text-decoration: none;
padding-left: 3px;
}
```

## See Font Awesome icons available

Go to the [Font Awesome library](http://fortawesome.github.io/Font-Awesome/icons/) to see the available icons.
Expand Down
132 changes: 0 additions & 132 deletions pages/mydoc/mydoc_no_password_prompts_scp.md

This file was deleted.

2 changes: 1 addition & 1 deletion pdf-mydoc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note that .sh scripts work only on Mac. If you're on Windows, install Git Bash and use that as your client.

echo 'Killing all Jekyll instances'
echo 'Kill all Jekyll instances'
kill -9 $(ps aux | grep '[j]ekyll' | awk '{print $2}')
clear

Expand Down
Binary file modified pdf/mydoc.pdf
Binary file not shown.
Binary file modified pdf/product1.pdf
Binary file not shown.

0 comments on commit 744754a

Please sign in to comment.