Reputation: 6210
I attempted to convert my mybook.adoc
to mybook.pdf
using pandoc
, and got the following error.
$ pandoc -s mybook.adoc -t asciidoc -o mybook.pdf
pandoc: cannot produce pdf output with asciidoc writer
Is there another tool that I should use instead of or in concert with pandoc
?
How can I convert asciidoc to pdf?
Upvotes: 18
Views: 45762
Reputation: 265
If you're using Visual Studio Code with AsciiDoc extension, Ctrl + SHFT + P
(or Shift ⇧ + Cmd ⌘ + P
in macOS) and type AsciiDoc: Export document as PDF
.
You will need to have asciidoctor-pdf
or wkhtmltopdf
installed according to the command instructions.
Upvotes: 16
Reputation: 617
In case if you have AsciiDoc plugin in Intellij, here is the way you can generate -
Upvotes: 1
Reputation: 33769
If you have Docker installed, you can use the AsciiDoctor Docker Image. Then you can use the image interactively or in batch mode as explained below:
Prerequisites
Install the Docker image:
$ docker pull asciidoctor/docker-asciidoctor
Create the pdf by executing the following command:
$ cd [directory to where my book.adoc is located]
$ docker run --rm -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf mybook.adoc
docker run
starts a Docker container--rm
cleanup - removes the Docker container after the command has been executed-v
mount a volume to the image$(pwd)
get the path to the current directory, e.g. the value of [directory to where my book.adoc is located]
abovedocuments
the name of the mounted volume in the running containerasciidoctor/docker-asciidoctor
the name of the Docker image that is used to create the Docker containerasciidoctor-pdf
the command that actually triggers the pdf generationmybook.adoc
the name of the AsciiDoc source file to generate the pdf fromSee also the docker run documentation
Upvotes: 21
Reputation: 6210
I now realize the ideal route from asciidoc to pdf is to first convert the asciidoc to docbook. This employs the intended sphere of asciidoc and a docbook->pdf converter using each in its separate area of concern.
Furthermore, instead of pandoc
I have found that when mathematical formulas are included, it was easier to use dblatex
for docbook->pdf conversion. Thus my conversion pipeline is the following:
asciidoc -> asciidoctor -> docbook -> dblatex -> pdf
A sample make file:
make: my.adoc
asciidoc -b docbook my.adoc
dblatex my.xml
This discussion page suggests that asciidoc is primarily designed to compile to docbook.
Upvotes: 4
Reputation: 39
Another workflow, which I use a lot, is to create HTML from your AsciiDoc file using the AsciiDoctor processor, linking a custom CSS stylesheet with print styling rules:
asciidoctor -a stylesheet=path-to-stylesheet.css file.adoc
You can then open the HTML file in your browser and print to PDF.
For more advanced styling, such as page numbering, headers, footers, page breaks and columns, you can use PrinceXML (or other similar products). This is a commandline processor that will convert the HTML file to PDF using the styling rules in the CSS used by the HTML file. PrinceXML applies styling rules that are in the CSS3 standard but which aren't yet supported by browsers, allowing you to create finely styled layouts.
Upvotes: 0
Reputation: 6210
Following @Remis's answer, I used asciidoctor's pdf backend.
I could not figure out how to install asciidoctor-pdf
on nixos, but managed to find the following alternative which worked:
asciidoctor -r asciidoctor-pdf -b pdf or asciidoctor-pdf
Upvotes: 0
Reputation: 651
Prerequisites: all that’s needed is Ruby (1.9.3 or above)
Install a native PDF converter for AsciiDoc - Asciidoctor PDF:
gem install asciidoctor-pdf --pre
Run:
asciidoctor-pdf mybook.adoc
You should get the file mybook.pdf in the same directory.
Upvotes: 23
Reputation: 325
The easiest way to convert AsciiDoc document to PDF is as follows -
Done.
Upvotes: 2
Reputation: 963
AsciiDoc has a couple of toolchains that will render PDFs from AsciiDoc source. You can use the Ruby-based AsciiDoc -> Prawn -> PDF toolchain developed by Asciidoctor, or you can use the older AsciiDoc -> DocBook -> FOP toolchain. These are rendering/publishing procedures, whereas Pandoc mainly provides for conversion and is best for converting from one o another type of source format.
Upvotes: 3