Asciidoc Before And After: The Cover Page

The cover page generated by asciidoctor-pdf is a bit bland by default.

It is actually, really, the internal title page that you see when you flip through the first pages of a book underneath the front cover.

Here’s the before and after view of what you can do to make a much nicer cover, and how to slip it into the final PDF render.

Before:

After:

Now, the title page is the first thing that asciidoctor-pdf will ever render and there is no way to sneak a page in ahead of it in the .asciidoc source file.

So, to add a proper cover page, we have to use an external tool called Apache PDFBox to slip the page into a post-processed file.

Generically, this looks like this, and is scripted as part of my document-building toolchain:

java -jar pdfbox-app-2.0.16.jar PDFMerger \
    cover-front-a4.pdf \
    sample-book.pdf \
    output-book.pdf

The PDFMerger command will splice together the two source PDFs and render it all to output-book.pdf. This is slightly different than the method described in a previous post, as it doesn’t directly use Asciidoc features to insert arbitrary PDF files. But it is another tool to get things done.

Oftentimes, I’ll also strategically add blank pages, where I think the content needs a bit of aesthetic separation.

This provides a much, much nicer looking cover to the overall work.