Giter Club home page Giter Club logo

asciidoctor-pdf's Introduction

Asciidoctor PDF: A native PDF converter for AsciiDoc

project chat Build Status (GitHub Actions) Latest Release

Asciidoctor PDF is a native PDF converter for AsciiDoc that serves the pdf backend. It bypasses the step of generating an intermediary format such as DocBook, Apache FO, or LaTeX in order to produce PDF. Instead, you use Asciidoctor PDF to convert your documents directly from AsciiDoc to PDF with Asciidoctor. The aim of this library is to take the pain out of creating PDF documents from AsciiDoc.

📎

The documentation for the latest, stable release of Asciidoctor PDF is available at https://docs.asciidoctor.org/pdf-converter/latest/.

If you’re looking for the documentation for Asciidoctor PDF 1.6, refer to the README in the v1.6.x branch. Asciidoctor PDF 1.6 is no longer being developed and will reach EOL later this year. You are encouraged to migrate to Asciidoctor PDF 2 as soon as possible.

Overview

Asciidoctor PDF converts an AsciiDoc document directly to a PDF document. The style and layout of the PDF are controlled by a dedicated theme file. To the degree possible, Asciidoctor PDF supports all the features of AsciiDoc that are supported by Asciidoctor. It also provides PDF-specific features. However, there are certain limitations imposed by the PDF format and the PDF library this extension uses.

Asciidoctor PDF uses the Prawn gem and Prawn’s extensions, such as prawn-svg and prawn-table, to generate a PDF document. Prawn is a general purpose PDF generator for Ruby that features high-level APIs for common needs like setting up the page and inserting images and low-level APIs for positioning and rendering text and graphics.

💡
For the latest Asciidoctor PDF features and fixes, see What’s New in Asciidoctor PDF.

Prerequisites

Asciidoctor PDF is built on Asciidoctor. Like Asciidoctor, Asciidoctor PDF is a Ruby application. Therefore, to use it, you’ll need a Ruby runtime.

The supported Ruby runtimes are Ruby 2.7 or greater and JRuby 9.2 or greater. However, we always recommend using the most recent release of Ruby or JRuby. All required libraries (i.e., gems) will be installed automatically when you install Asciidoctor PDF, which will be covered in the next section.

To check if you have Ruby available, run the ruby command to print the installed version:

$ ruby -v

Make sure this command reports a Ruby version that starts with 2.7 (or a JRuby version that starts with 9.2). If so, you’re ready to proceed. If not, head over to rvm.io to get RVM and use it to install Ruby.

Install Asciidoctor PDF

You can install Asciidoctor PDF using the gem install command. We’ll use this command to install the Asciidoctor PDF gem named asciidoctor-pdf that’s published on RubyGems.org. Pass the name of the gem to the gem install command as follows:

$ gem install asciidoctor-pdf

Installing Asciidoctor PDF will install a number of other gems mentioned in these docs, including asciidoctor, prawn, prawn-svg, prawn-table, prawn-icon, and ttfunk. For the most part, the versions of these dependencies are locked to the version of Asciidoctor PDF. The patch versions are allowed to vary. Please note that the minimum supported version of the asciidoctor gem (Asciidoctor) is 2.0.10.

For further installation information about installing Asciidoctor PDF, see the installation documentation. For troubleshooting help, see Installation troubleshooting.

Install a prerelease or development version

To install the latest prerelease of the asciidoctor-pdf gem from RubyGems.org (if a prerelease is available), use the following command:

$ gem install asciidoctor-pdf --pre

You can also run the code from source if you want to use a development version or participate in development.

Optional dependencies

There are several optional features of this converter that require additional gems to be installed. Those features are as follows.

Source highlighting

You’ll need to install a syntax highlighter to use source highlighting (build-time only).

PDF optimization

If you want to optimize your PDF, you’ll need rghost or hexapdf. See Optimize the PDF for installation and usage instructions.

Automatic hyphenation

To turn on automatic hyphenation using the hyphens attribute, you’ll need to install the text-hyphen gem:

$ gem install text-hyphen
Accelerated image decoding

Ruby is not particularly fast at decoding images, and the image formats it supports are limited. To help, you can install prawn-gmagick, which delegates the work of decoding images to GraphicsMagick. Refer to Supporting additional image file formats for instructions about how to enable this integration.

Check the minimum supported version table to make sure you’re using a supported version of the dependency.

Run the Application

Assuming all the required gems install properly, verify you can run the asciidoctor-pdf script:

$ asciidoctor-pdf -v

If you see the version of Asciidoctor PDF printed, you’re ready to use Asciidoctor PDF!

Let’s grab an AsciiDoc document to distill and start putting Asciidoctor PDF to use.

If you don’t already have an AsciiDoc document to work with, you can use the basic-example.adoc file found in the examples directory of this project. Copy it to the current directory as follows:

$ cp examples/basic-example.adoc .

Let’s take a look at the contents of that file.

It’s time to convert the AsciiDoc document directly to PDF.

Convert AsciiDoc to PDF

You’ll need the rouge gem installed to run this example since it uses the source-highlighter attribute with the value of rouge.

Converting to PDF is as straightforward as running the asciidoctor-pdf script using Ruby and passing the AsciiDoc document as the first argument:

$ asciidoctor-pdf basic-example.adoc

This command is a shorter way of running asciidoctor with the PDF converter and backend enabled:

$ asciidoctor -r asciidoctor-pdf -b pdf basic-example.adoc

The asciidoctor-pdf command saves you from having to remember these low-level options. That’s why we provide it.

When the script completes, you should see the file basic-example.pdf in the current directory. Asciidoctor creates the output file in the same directory as the input file by default. Open the basic-example.pdf file with a PDF viewer to see the result.

Screenshot of PDF document
Figure 1. Example PDF document rendered in a PDF viewer

For more information about how to use Asciidoctor PDF and PDF-specific AsciiDoc syntax, see the Asciidoctor PDF documentation.

Themes

The layout and styling of the PDF is driven by a YAML configuration file. To learn how the theming system works and how to create and apply custom themes, refer to the Asciidoctor PDF theming documentation.

Contributing

See the contributing guide. To help develop Asciidoctor PDF, or to simply use the development version, refer to the developing and contributing code guide.

Authors

Asciidoctor PDF was written by Dan Allen and Sarah White of OpenDevise Inc. on behalf of the Asciidoctor Project.

Copyright © 2014-present OpenDevise Inc. and the Asciidoctor Project. Free use of this software is granted under the terms of the MIT License.

For the full text of the license, see the LICENSE file. Refer to the NOTICE file for information about third-party Open Source software in use.

asciidoctor-pdf's People

Contributors

abatalev avatar ahus1 avatar chloerei avatar darevan avatar darinpope avatar das-g avatar fabienlaunay avatar ggrossetie avatar graphitefriction avatar gregturn avatar habamax avatar janicemhdc avatar jessedoyle avatar juracy avatar klonfish avatar leif81 avatar lurch avatar maneex avatar meisterluk avatar modprog avatar mojavelinux avatar nawroth avatar ntfc avatar otavio avatar pravi avatar r0ckarong avatar rui-castro avatar slonopotamus avatar theimdal avatar zyuhel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asciidoctor-pdf's Issues

Add support for image links

Images can also serve as links. Detect the presence of the link attribute on the image and add an anchor point around the image canvas.

There's now an example in the chronicles.adoc document in the examples directory.

Fallback fonts support

Seems like fallback fonts settings in theme.yml not working yet, please implement the feature in the future, without fallback fonts I can not render an document write in CJK characters.

The project is great! thanks for all contributors.

optimize-pdf cannot handle file names with spaces

./optimize-pdf /cygdrive/f/Documents/oracle/Oracle\ Installation\ auf\ SLES.pdf
./optimize-pdf: line 9: [: Too many arguments.
Error: /undefinedfilename in (/cygdrive/f/Documents/oracle/Oracle)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1177/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.06: Unrecoverable error, exit code 1

Page numbers

Would be good to have page numbers for printed documents.

Failed test on a book

After having some success on small files, I decided to try this converter on a randomly selected book:
Closure Cookbook

This is my output:

$ ruby /opt/asciidoctor-pdf/bin/asciidoctor-pdf book.asciidoc
/opt/asciidoctor-pdf/lib/asciidoctor-pdf/implicit_header_processor.rb:25:in readline': end of file reached (EOFError) from /opt/asciidoctor-pdf/lib/asciidoctor-pdf/implicit_header_processor.rb:25:inblock in process'
from /opt/asciidoctor-pdf/lib/asciidoctor-pdf/implicit_header_processor.rb:15:in open' from /opt/asciidoctor-pdf/lib/asciidoctor-pdf/implicit_header_processor.rb:15:inprocess'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:818:in []' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:818:inpreprocess_include'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:627:in process_line' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:161:inpeek_line'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:660:in peek_line' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/reader.rb:311:inskip_blank_lines'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/parser.rb:1991:in parse_block_metadata_lines' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/parser.rb:278:innext_section'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/parser.rb:291:in next_section' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/parser.rb:52:inparse'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor/document.rb:448:in parse' from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor.rb:1337:inload'
from /var/lib/gems/1.9.1/gems/asciidoctor-1.5.0/lib/asciidoctor.rb:1355:in load_file' from /opt/asciidoctor-pdf/bin/asciidoctor-pdf:66:in

'

Does asciidoctor-pdf support include:: yet?
Thanks,
-Shaun

How to use on Windows ?

Hi, i've used raw Prawn in my Rails application to generate reports, it's interesting to find this gem, but i don't know how to use it in Windows environment. Do you have any way to use ? Thank you very much.

Using an image results in an error

I'm trying to put an image into a document. Using this syntax:

.Good Luck!
image:graphics/Horseshoe.jpg[
"Lucky Horseshoe", width=128,
link="graphics/Horseshoe.jpg"]

I get the following error:

~/dvcs/github/asciidoctor-pdf/bin/asciidoctor-pdf README.adoc
asciidoctor: WARNING: gem 'thread_safe' is not installed. This gem recommended when using custom backend templates.
Failed to parse formatted text: <span class="image"><a class="image" href="graphics/Horseshoe.jpg"><img src="graphics/Horseshoe.jpg" alt="Lucky Horseshoe" width="128"></a></span>

and produces a pdf document with the error text embedded in it. I'm technically shallow with how asciidoctor-pdf and its rendering process works, so all I can do is compare it to rendering html via asciidoc, and the github adoc renderer. Both of them seem to work with this example.

Images are currently not parsed

Image references like

image:images/image1.png[]

are currently not parsed and thus not inserted into the pdf:

Failed to parse formatted text: <span class="image"><img src="images/image1.png" alt="image1"></span>

Can't install

I haven't been able to install asciidoctor-pdf in my system configuration, as opposed to one tailored specifically for asciidoctor-pdf. I need this because I need to call /usr/bin/asciidoctor-pdf
(from a mac osx app, asciihelper.

Below is a log of my failure to install: (1) Just try to do it - fail on pdf-core (2) Install pdf-core by itself; (3) retry and fail with message that contradicts the facts: pdf-core was installed,
and Ruby is of version >= 1.9.3.

(1) Just try to do it.

$ rvm system
$ rvm list

rvm rubies

   ruby-1.9.3-p429 [ x86_64 ]
   ruby-1.9.3-p547 [ x86_64 ]
   ruby-2.0.0-p195 [ x86_64 ]
   ruby-2.0.0-p451 [ x86_64 ]
   ruby-2.1.0 [ x86_64 ]
   ruby-2.1.1 [ x86_64 ]
 * ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Enter your password to install the bundled RubyGems to your system: 
Using rake (10.3.2) 
Using Ascii85 (1.0.2) 
Using afm (0.2.2) 
Using asciidoctor (1.5.0.rc.6) 
Using coderay (1.1.0) 
Installing pdf-core (0.2.5) 
Gem::InstallError: pdf-core requires Ruby version >= 1.9.3.
An error occurred while installing pdf-core (0.2.5), and Bundler cannot continue.
Make sure that `gem install pdf-core -v '0.2.5'` succeeds before bundling.

(2) Install pdf-core by itself

$ gem install pdf-core -v '0.2.5'
Fetching: pdf-core-0.2.5.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
$ sudo gem install pdf-core -v '0.2.5'
Fetching: pdf-core-0.2.5.gem (100%)
Successfully installed pdf-core-0.2.5
Parsing documentation for pdf-core-0.2.5
Installing ri documentation for pdf-core-0.2.5
1 gem installed
  1. retry and fail with message that contradicts the facts: pdf-core was installed,
    and Ruby is of version >= 1.9.3.
$ bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using rake (10.3.2) 
Using Ascii85 (1.0.2) 
Using afm (0.2.2) 
Using asciidoctor (1.5.0.rc.6) 
Using coderay (1.1.0) 
Installing pdf-core (0.2.5) 
Gem::InstallError: pdf-core requires Ruby version >= 1.9.3.
An error occurred while installing pdf-core (0.2.5), and Bundler cannot continue.
Make sure that `gem install pdf-core -v '0.2.5'` succeeds before bundling.

Nil can't be coerced into a float -- happens with stylesheet

I get the error listed bellow when I use a style sheet with asciidoctor pdf. No pdf is generated.
Without the stylesheet, the pdf is generated without error.

$ asciidoctor-pdf -a pdf-style=base-theme.yml Poetry_8.ad 
/Users/carlson/.rvm/gems/ruby-2.1.1/gems/prawn-1.2.1/lib/prawn/document.rb:437:in `-': nil can't be coerced into Float (TypeError)

here is the style sheet:

base:
  font_size: 9
  line_height_length: 10

The error occurs with and without the trailing blank line.

Cross references don't jump to linked section

I tried asciidoctor-pdf today. It's looking really nice on my sample document!
One thing I noticed is that cross references are clickable within the pdf, but the user isn't taken to the target. I'm not 100% sure if cross references should already work or not.

Using asciidoctor-pdf-1.5.0.alpha.5 and a slightly modified example.adoc, see below.

= Document Title
Doc Writer <doc@example.com>
:doctype: book
:source-highlighter: coderay
:listing-caption: Listing

A simple cross reference <<Introduction>>.



== Introduction

A paragraph followed by a simple list with square bullets.

[square]
* item 1
* item 2


Here's how you say "`Hello, World!`" in Prawn:

.Create a basic PDF document using Prawn
[source,ruby]
----
require 'prawn'

Prawn::Document.generate 'example.pdf' do
  text 'Hello, World!'
end
----

Type size

Would be good to have a way of controlling the "master" font size. In the image of a pdf file attached to Issue #38, the type size is great for the screen but looks way too big when printed.

imagesdir is resolved relatively to document

imagesdir is resolved relatively to document location.

Setting

:imagesdir:   /home/thorsten/.asciidoc/images

results in

./asciidoctor-pdf document.adoc
WARNING: /home/thorsten/bin/asciidoctor-pdf/bin/home/thorsten/.asciidoc/images/DIRECTORY/FILE.png not found

Generation of examples PDF fails (Prawn version problem)

Hi, I've checkout the project and followed the instructions for the installation.
Now I'm trying to convert the example/chronicles.adoc file without success:

I've tried with the latest version of asciidoctor I'm using (1.5.0.preview.8) and I get this:

/Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:1027:in `render_table_node': undefined method `table' for #<Asciidoctor::PdfRenderer:0x007feb996d1140> (NoMethodError)
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:80:in `render_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `block in render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `each'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:92:in `render_section_content'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:251:in `render_section_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:80:in `render_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `block in render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `each'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:92:in `render_section_content'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:251:in `render_section_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:80:in `render_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `block in render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `each'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:88:in `render_children'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:166:in `render_document_node'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:51:in `block in render'
    from /Users/ajo/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/prawn-1.1.0/lib/prawn/document.rb:228:in `instance_eval'
    from /Users/ajo/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/prawn-1.1.0/lib/prawn/document.rb:228:in `initialize'
    from /Users/ajo/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/prawn-1.1.0/lib/prawn/document.rb:144:in `new'
    from /Users/ajo/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/prawn-1.1.0/lib/prawn/document.rb:144:in `generate'
    from /Users/ajo/Dev/Ruby/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:45:in `render'
    from ../bin/asciidoctor-pdf:68:in `<main>'

So, I then re-installed the latest 'stable' version of asciidoctor version 1.4 and now I get this:

../bin/asciidoctor-pdf:59:in `<main>': undefined method `build_registry' for Asciidoctor::Extensions:Module (NoMethodError)

I've seen during the installation that the Prawn library had a lots of changes recently.
I then decided to downgrade Prawn from version 1.1.0 to version 1.0.0 ... and it now works !

So I guess there is some kind of breaking change in the latest version of Prawn.
I'm really not a Ruby guy, so I prefer to let you solve this issue, sorry for that.
Thanks a lot for this project,
cheers
Ozb

Refactor Asciidoctor PDF as a formal Asciidoctor converter

Asciidoctor PDF was developed before the introduction of the Asciidoctor converter API. The code needs to be refactored to use the formal converter extension API (see https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter.rb).

By refactoring Asciidoctor PDF as a formal Asciidoctor converter, we eliminate the need to invoke it through a specialized API. Instead, we'll be able to load it as an extension library simply by requiring the gem and setting the backend to pdf. For example:

$ asciidoctor -b pdf -r asciidoctor-pdf sample.adoc

This solves all the current shortcomings of the CLI (issues #1, #2, #23), since parsing the commandline arguments will be handled by the asciidoctor command.

Like is done in the Asciidoctor EPUB3 extension, we can still provide a dedicated command that sets the backend and delegates to the main Asciidoctor CLI. For example, the asciidoctor-pdf command would simply look like:

#!/usr/bin/env ruby

require File.join File.dirname(__FILE__), '../lib/asciidoctor-pdf'
require 'asciidoctor/cli'

options = Asciidoctor::Cli::Options.new backend: 'pdf'
if (options.parse! ARGV) == 0
  exit 0
else
  invoker = Asciidoctor::Cli::Invoker.new options
  GC.start
  invoker.invoke!
  exit invoker.code
end

Labeled lists inside a sidebar are not generated

asciidoctor-pdf version: alpha3.
toolchain: via gradle plugin

Snippet that does not generate

.Gilb's QA Values
****
Efficiency:: We will always strive to find and implement the most cost effective methods 
to assure long term system quality.
****

Disable the implicit header processor extension by default

Disable the implicit header processor as it is messing up includes and generally changing the default behavior of AsciiDoc / Asciidoctor.

In particular, it is not resolving includes correctly when the current working directory is different than the master file.

We can still include the extension in asciidoctor-pdf and require that it be specifically enabling using the require option / flag.

asciidoctor-pdf-1.5.0.alpha.1 - Invalid multibyte char (US-ASCII) error when called via asciidoctorj

This issue could be anywhere in the tool chain, but I have taken the approach to test this from the asciidoctor-gradle-plugin.

The build.gradle script contains

buildscript {
    repositories { 
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
        classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.0'    
    }
}

apply plugin: 'org.asciidoctor.gradle.asciidoctor'
apply plugin: 'com.github.jruby-gradle.base'

dependencies {
    gems ('rubygems:asciidoctor-pdf:1.5.0.alpha.1') {
        exclude module : 'asciidoctor'
    }
}

asciidoctor {
    requires = ['asciidoctor-pdf']
    sourceDocumentNames = files('src/asciidoc/slides.adoc')
    sourceDir = new File('src/asciidoc')
    backends = ['pdf']

    dependsOn jrubyPrepareGems
    gemPath = jruby.gemInstallDir
}

(This needs Gradle 2.0+)

Running gradle asciidoctor --stacktrace yields.

Caused by: org.jruby.exceptions.RaiseException: (SyntaxError) /Users/schalkc/Projects/jruby-gradle-dev/TMP3/build/vendor/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf/converter.rb:918: invalid multibyte char (US-ASCII)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1083)
    at RUBY.(root)(jar:file:/Users/schalkc/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.9/93c1906ed4d212ec7fb2fc810da206f1f2a034b4/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1)
    at RUBY.require(jar:file:/Users/schalkc/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.9/93c1906ed4d212ec7fb2fc810da206f1f2a034b4/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:126)
    at RUBY.require_relative(file:/Users/schalkc/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.9/93c1906ed4d212ec7fb2fc810da206f1f2a034b4/jruby-complete-1.7.9.jar!/jruby/kernel19/kernel.rb:21)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1083)
    at RUBY.(root)(/Users/schalkc/Projects/jruby-gradle-dev/TMP3/build/vendor/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf.rb:3)
    at RUBY.(root)(jar:file:/Users/schalkc/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.9/93c1906ed4d212ec7fb2fc810da206f1f2a034b4/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1)
    at org.asciidoctor.gradle.AsciidoctorTask.processAsciidocSources(AsciidoctorTask.groovy:168)

The source files are effectively a split copy of the example on the asciidoctor-pdf README.

slides.adoc

= Document Title
Doc Writer <[email protected]>
v0.0.0.1, 2014
:doctype: book
:source-highlighter: coderay
:listing-caption: Listing
:toc:

A simple http://asciidoc.org[AsciiDoc] document.

== Introduction

A paragraph followed by a simple list with square bullets.

[square]
* item 1
* item 2

include::slides2.adoc[]

:numbered!:

== Not numbered from hereon

slides2.adoc

== Code Example 2

Here's how you say "`Hello, World!`" in Prawn:

.Create a basic PDF document using Prawn
[source,ruby]
----
require 'prawn'

Prawn::Document.generate 'example.pdf' do
  text 'Hello, World!'
end
----

Exception if asciidoc contains table of contents

Hi,

if a asciidoc file contains a table of contents like

:toc:
toc::[]

generation ends with the following exception:

/.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:1100:in `render_toc_node': undefined method `each' for nil:NilClass (NoMethodError)
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:81:in `render_node'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in `block in render_children'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in `each'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in `render_children'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:167:in `render_document_node'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:52:in `block in render'
    from /var/lib/gems/1.9.1/gems/prawn-1.0.0/lib/prawn/document.rb:228:in `instance_eval'
    from /var/lib/gems/1.9.1/gems/prawn-1.0.0/lib/prawn/document.rb:228:in `initialize'
    from /var/lib/gems/1.9.1/gems/prawn-1.0.0/lib/prawn/document.rb:144:in `new'
    from /var/lib/gems/1.9.1/gems/prawn-1.0.0/lib/prawn/document.rb:144:in `generate'
    from /.../asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:46:in `render'
    from ../asciidoctor-pdf/bin/asciidoctor-pdf:68:in `<main>'

Where is output file

If I execute

$ ./bin/asciidoctor-pdf  foo.ad

inside my install directory /mylongpath/git/asciidoctor-pdf, i find the output file foo.pdf in that directory. On the other hand, if I execute it via

executeCommand("/mylongpath/git/asciidoctor-pdf", ["foo.ad"])

from within my MacOS program, I cannot find the output file. Note that

executeCommand("/usr/bin/asciidoctor", ["foo.ad"])

does produce foo.html in the same directory as foo.ad.

Below is the log from the program. Note that it would have been better to call /usr/local/bin/asciidoctor-pdf, but so far I can only install by cloning the repo and running bundle so as to install it in the cloned directory.

Recalled: documentURL => Optional("file:////Users/carlson/Dropbox/prog/Swift/adviewer/poetry/hib.ad")

LATEX: false
location: <WebScriptObject: 0x6080000193f0>
href: about:blank
executeCommand
Running: /Users/carlson/Dropbox/prog/git/asciidoctor-pdf/bin/asciidoctor-pdf
Args: [//Users/carlson/Dropbox/prog/Swift/adviewer/poetry/hib.ad]
/Library/Ruby/Gems/2.0.0/gems/tilt-2.0.1/lib/tilt/template.rb:83:in `initialize': /Users/carlson/Dropbox/prog/git/asciidoctor-pdf/bin/../data/templates/inline_quoted.html.slim is not valid US-ASCII (Encoding::InvalidByteSequenceError)
    from /Library/Ruby/Gems/2.0.0/gems/tilt-2.0.1/lib/tilt/mapping.rb:136:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/tilt-2.0.1/lib/tilt/mapping.rb:136:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/tilt-2.0.1/lib/tilt.rb:43:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:268:in `block in scan_dir'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:245:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:245:in `scan_dir'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:120:in `block in scan'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:97:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:97:in `scan'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/template.rb:77:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/factory.rb:219:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/converter/factory.rb:219:in `create'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/document.rb:985:in `create_converter'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/document.rb:905:in `update_backend_attributes'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor/document.rb:379:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor.rb:1337:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor.rb:1337:in `load'
    from /Library/Ruby/Gems/2.0.0/gems/asciidoctor-1.5.0/lib/asciidoctor.rb:1355:in `load_file'
    from /Users/carlson/Dropbox/prog/git/asciidoctor-pdf/bin/asciidoctor-pdf:79:in `<main>'
Output: 

Converting to PDF gives "undefined method `size' for 2..2:Range"

Trying to convert the WildFly lab at:

https://github.com/arun-gupta/wildfly-lab/tree/master/docs

to PDF and getting the following error:

NoMethodError: undefined method `size' for 2..2:Range
render_document_node at
/Users/arungupta/workspaces/asciidoctor-pdf/bin/../lib/asciidoctor/pdf_renderer.rb:171
render at
/Users/arungupta/workspaces/asciidoctor-pdf/bin/../lib/asciidoctor/pdf_renderer.rb:47
instance_eval at org/jruby/RubyBasicObject.java:1536
initialize at
/Users/arungupta/.rvm/gems/jruby-1.7.9/gems/prawn-0.13.1/lib/prawn/document.rb:217
generate at
/Users/arungupta/.rvm/gems/jruby-1.7.9/gems/prawn-0.13.1/lib/prawn/document.rb:121
render at
/Users/arungupta/workspaces/asciidoctor-pdf/bin/../lib/asciidoctor/pdf_renderer.rb:41
(root) at
/Users/arungupta/workspaces/asciidoctor-pdf/bin/asciidoctor-pdf:36

asciidoctor-pdf.js

I would LOVE to see a JavaScript version of asciidoctor-pdf. Creation of PDF straight from Atom- or Brackets-Plugins without installation of other software!

Use asciidoctor-theme as default

I'm proposing we switch the default theme to asciidoctor-theme.yml because I think it would be a good to have all asciidoctor backends, browser extensions, and editor extensions using the same theme by default. That way when someone switches between backends, browsers, editors, etc they get a common look and feel / branding. We did this for Brackets (asciidoctor/brackets-asciidoc-preview#9 ) not too long ago.

WDYT?

Callout number support

asciidoctor-pdf does not seem to support callouts. Is there a way to enable this?

This may or may not be related to #15, I'm not sure.

No images when data-uri is set

Setting :data-uri:

results in

./asciidoctor-pdf document.adoc
WARNING: data:image/png;base64, not found

The resulting PDF does not have the image. Unsetting :data-uri: resolves the issue.

Since :data-uri: does only make sense for HTML output, asciidoctor-pdf should - in my opinion - ignore this value.

Failed to parse formatted text

I'm getting this when rendering.

asciidoctor: WARNING: 01-websocket-protokol.asc: line 71: list item index: expected 2, got 1
asciidoctor: WARNING: 01-websocket-protokol.asc: line 76: list item index: expected 3, got 1
asciidoctor: WARNING: 01-websocket-protokol.asc: line 77: list item index: expected 4, got 2
asciidoctor: WARNING: 01-websocket-protokol.asc: line 78: list item index: expected 5, got 3
asciidoctor: WARNING: 01-websocket-protokol.asc: line 79: list item index: expected 6, got 4
Failed to parse formatted text: image</spa
n>
E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:1004:in block in render_table_node': undefined m ethod*' for nil:NilClass (NoMethodError)
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:1004:in map' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:1004:inrender_table_node'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:81:in render_node' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inblock in render_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in each' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inrender_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:93:in render_section_content' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:252:inrender_section_node'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:81:in render_node' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inblock in render_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in each' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inrender_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:93:in render_section_content' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:252:inrender_section_node'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:81:in render_node' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inblock in render_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:in each' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:89:inrender_children'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:167:in render_document_node' from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:52:inblock in render'
from E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/prawn-1.0.0/lib/prawn/document.rb:228:in insta nce_eval' from E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/prawn-1.0.0/lib/prawn/document.rb:228:ininiti
alize'
from E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/prawn-1.0.0/lib/prawn/document.rb:144:in new' from E:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/prawn-1.0.0/lib/prawn/document.rb:144:ingener
ate'
from E:/asciidoctor-pdf/lib/asciidoctor/pdf_renderer.rb:46:in render' from E:/asciidoctor-pdf/bin/asciidoctor-pdf:68:in

'

Enable Font Awesome icons

The PDF uses text tags instead of fontawesome icons for admonitions, even if you add -a icons=font to the command line. Any hints?

Add support for inline images

Add support for the inline image macro. This requires adding a convenience method for placing an image in the flow of text. It would be nice to have direct support for this in Prawn, though we can get away with using a method in Asciidoctor PDF until it becomes available upstream.

Allow the page number banner to be configured

Allow the banner line that shows the page number to be configured, for instance to include the total number of pages. Currently, it's possible to override the page_number_pattern method in the converter, but perhaps this should be part of the theme or some sort of content template file.

Source code encoding issue with Ruby 1.9 (was: Error running)

I get an error running it even with minimal content like:

= Title

Content
$ asciidoctor-pdf tmp.adoc 
/var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf.rb:3:in `require_relative': /var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf/converter.rb:918: invalid multibyte char (US-ASCII) (SyntaxError)
/var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf/converter.rb:918: invalid multibyte char (US-ASCII)
/var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf/converter.rb:918: syntax error, unexpected $end, expecting ']'
      open, close, is_tag = ['“', '”', false]
                                ^
    from /var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/lib/asciidoctor-pdf.rb:3:in `<top (required)>'
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /var/lib/gems/1.9.1/gems/asciidoctor-pdf-1.5.0.alpha.1/bin/asciidoctor-pdf:3:in `<top (required)>'
    from /usr/local/bin/asciidoctor-pdf:23:in `load'
    from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

Tilt dependency?

Is the requirement for Tilt ~> 2.0.1 rigid? I'm having difficulties finding any combination of versions which will allow me to run the gem alongside middleman:

Bundler could not find compatible versions for gem "tilt":
  In Gemfile:
    middleman-core (>= 0) ruby depends on
      tilt (< 2.0, ~> 1.4.1) ruby

    tilt (2.0.1)

optimize-pdf does not optimize

Just an example for a document with 26 PNGs:

  • the Asciidoctor generated HTML file is 2.06 MiB
  • Asciidoctor PDF generated PDF file is 1.52 MiB
  • the optimize-pdf "optimized" PDF file is 3.70 MiB

`--help` command line argument

Although asciidoctor-pdf it's fairly simple to use, I don't like the error I get when I run asciidoctor-pdf --help xD.

Setup a test suite

Because, quality.

It probably makes sense to use whatever Prawn is using so that we have lots of examples of how to create tests for Prawn data structures and output.

Hint to prevent page break

It would be good to have a way inserting hints (invisible in all asciidoctor output) that indicate when a page break is a good thing. (There may be other hints that are desirable as well, like when it is good to keep things together). Attached is an example. At the bottom of the page is the title of the poem that appears on the next page. That poem is just five lines long. The poem and the heading should go together --- sometimes one poem per page, or a page break at the end of each poem is a good solution.

TeX (or LaTeX) do a fantastic job of controlling the page break, even without hinting. It "knows" what things should go together, where good, bad, and terrible breaks are. There is a lot of sophisticated behind-the-scenes optimization going on. I don't know if there is an engine out there for managing page breaks that one could use.

In any case, the current form of asciidoctor-pdf is great progress!

dylan_poetry

Add text hyphenation

Hi there,
it would be great if asciidoctor-pfd could insert hyphens at the appropriate places in german texts. I had to manually set this up in asciidoctor-fopub (which was a hassle). Is there a way to archive this in asciidoctor-pdf? I've set :lang: de in the document header.

Thanks

Poetry / verse style

Would be desirable not to have gray bars on left of poems. Also, to be able to move the left
margin to the left, since poems may consist of short lines. Of course line length varies. See pdf image in Issue #38.

Notes about Prawn 1.0 roadmap

Hello!

Thanks for building an extension to Prawn. I'm filing this issue to let you know that we're currently working towards a stable 1.0 release of Prawn, and I want to invite you to be part of the discussion around that.

We will only have one more major release before 1.0 is shipped: it will be labeled 0.15 and it will be cut on 2014-02-16.

The functionality of the 0.15 release will be largely the same as what we ship in 1.0, so if you want to test your project against the newest Prawn code, that would be a good time to
do it. You can also get a head start by trying out what is on master now, and reporting any problems you encounter.

If your project is sufficiently up to date and is able to run on the latest Prawn code, the next step would be to take a look at our API compatibility plans, which are described in detail here:

https://groups.google.com/forum/#!topic/prawn-ruby/dbTSnlDhED0

Here's the very quick summary:

  • If your project is using stable APIs and ONLY stable APIs, it will be safe for you to lock your Prawn dependency to "~> 1.0".
  • If your project is using stable and extension APIs, keep an eye out for deprecation warnings, and lock your gem to
    a range of known good minor Prawn versions. (i.e. ">= 1.0", "<=1.x"). We want to eventually apply semantic versioning to our extension API as well, but we're not there yet.
  • The use of experimental APIs in your extensions is not recommended unless you consider your own code to be experimental as well. Instead, work with us to figure out what it would take to get these experimental APIs stabilized or extracted.

I know this is a little bit confusing, and my hope is that in the not too distant future we'll be able to cut a Prawn 2.0 release that has much better support for downstream dependencies.

Until that time, what we lack in stability we'll try to make up in support for your project. Use the Prawn mailing list to contact us about any concerns or breakage, help us work on API stabilization, and let us know when you need extension points to support your project.

Thanks!
-greg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.