我写了一个带有includes和以下结构的asciidoctor文档:
/mydoc.adocs
/chap1/
/chap1/chap1.adoc
/chap1/sections/
/chap1/sections/section1.adoc
/chap1/images/
/chap1/images/myimg.png
/img/
/img/...some other images here我使用以下命令生成我的PDF:
asciidoctor-pdf -b pdf mydoc.adocmydoc.adoc如下所示:
:doctype: book
:encoding: utf-8
:imagesdir: img
= My life...
Thierry <thierry@mywebsite.com>
include::chap1/chap1.adoc[]chap1.adoc如下所示:
[[_Chap1]]
== Foo
include::sections/section1.adoc[]最后,section1.adoc如下所示:
=== Bla bla
image::../images/myimg.png[label]如果我为section1.adoc (asciidoctor-pdf PDF -b pdf section1.adoc)生成pdf,它将包含图像。但是如果我从根目录生成mydoc.adoc (asciidoctor-pdf PDF -b pdf mydoc.adoc),它不包括图像。
我得到了以下错误:
asciidoctor: WARNING: image to embed not found or not readable: C:/myproject/images/myimg.png我看起来好像这一代人不关心路径……
有人能帮帮我吗?
Th。
发布于 2020-05-03 02:13:27
不幸的是,你的请求有点老了,但我遇到了同样的问题,并按如下方式解决了它。我正在运行Ubuntu20.04,但安装了podman,并使用CentOS7容器在其中安装了asciidoctor-pdf。因此,您必须选择任何能够运行容器的操作系统。
安装dockerized asciidoctor-pdf (带有.png-support)
标准安装的asciidoctor-pdf和官方docker集线器镜像不支持使用.png文件将.adoc转换为.pdf。您将得到一个错误。在示例中,我尝试将service-documentation.adoc转换为service-documentation.pdf:
$ podman run --rm -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf service-documentation.adoc
Trying to pull docker.io/asciidoctor/docker-asciidoctor...
Getting image source signatures
Copying blob 85a3f8045a5f done
Copying blob 6cf8cbf780aa done
Copying blob c9b1b535fdd9 done
Copying blob 07903a9ac4b8 done
Copying blob 102cbf696e41 done
Copying config 0c383e26e3 done
Writing manifest to image destination
Storing signatures
asciidoctor: WARNING: could not embed image: image.png; PNG uses unsupported interlace method; install prawn-gmagick gem to add support
asciidoctor: 准备容器
我正在使用podman创建所需的容器
运行CentOS7容器
我使用来自docker.io的CentOS7容器在其中安装asciidoctor-pdf:
podman run -ti --name asciidoctor-pdf -v $(pwd):/data centos:centos7 /bin/bash安装epel repo并更新系统
需要用于企业linux的Etra包,因此使用以下命令安装yum repu:
$ yum install epel-release -y
$ yum update -y 安装ruby
Asciidoctor使用ruby,安装ruby:
$ yum install which git wget -y
$ curl -L get.rvm.io |bash -s stable
$ gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ curl -L get.rvm.io |bash -s stable
$ source /etc/profile.d/rvm.sh
$ rvm reload
$ rvm requirements run
$ rvm install 2.6
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]安装asciidoctor-pdf
现在可以使用以下命令安装没有完全.png支持的Asciidoctor:
$ gem install asciidoctor-pdf --pre
$ asciidoctor-pdf -v
Asciidoctor PDF 1.5.3 using Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]) (lc:US-ASCII fs:US-ASCII in:US-ASCII ex:US-ASCII)安装Graphics Magick (用于prawn gmagick)
为了支持.png文件,我们需要gem prawn gmagick。对此的要求是图形魔术。使用以下命令进行安装:
$ yum install GraphicsMagick-c++ GraphicsMagick-devel libpng libjpeg libpng-devel ghostscript libtiff libtiff-devel freetype freetype-devel jasper jasper-devel -y
$ mkdir ~/temp
$ cd ~/temp
$ wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz
$ tar xvzf GraphicsMagick-LATEST.tar.gz
$ cd GraphicsMagick-1.3.35/
$ ./configure
$ make install
$ gm version
GraphicsMagick 1.3.35 2020-02-23 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2020 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP no
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 yes
JPEG yes
Little CMS no
Loadable Modules no
Solaris mtmalloc no
Google perftools tcmalloc no
OpenMP yes (201107 "3.1")
PNG yes
TIFF yes
TRIO no
Solaris umem no
WebP no
WMF no
X11 no
XML no
ZLIB yes
...
...安装prawn gmagick
现在,我们可以使用以下命令继续安装gem prawn gmagick:
$ gem install prawn-gmagick
Fetching prawn-gmagick-0.0.9.gem
Building native extensions. This could take a while...
Successfully installed prawn-gmagick-0.0.9
Parsing documentation for prawn-gmagick-0.0.9
Installing ri documentation for prawn-gmagick-0.0.9
Done installing documentation for prawn-gmagick after 0 seconds
1 gem installed安装已完成,请退出容器:
[root@4e5f3c876eb5 GraphicsMagick-1.3.35]# exit
exit
user@hostname-linux:~/git/service-docs$运行asciidoctor-pdf
现在我们可以使用我们创建的带有.png支持的asciidoctor-pdf容器,如下所示:
启动容器
$ podman start asciidoctor-pdf
$ podman exec -ti asciidoctor-pdf /bin/bash将.adoc转换为.pdf
将.adoc转换为.pdf:
asciidoctor-pdf file.adoc -o /data/file.pdf退出容器:
[root@4e5f3c876eb5 GraphicsMagick-1.3.35]# exit
exit
user@hostname-linux:~/git/service-docs$提示转换后的文件位于cwd中。
user@hostname-linux:~/git/service-docs$ ls -la
total 748
...
-rw-r--r-- 1 user user 744314 Mai 2 13:40 file.pdf提示:这并不是asciidoctor的问题。Asciidoctor能够将带有png文件的asciidoc格式的文档转换为html。在将带有png文件的asciidoc文档转换为pdf时,您似乎需要来自prawn magick的附加库。大虾魔术需要Graphicks Magick。在安装了.pdf之后,所有的依赖都会被满足,直接将.adoc转换成.pdf。
问候
https://stackoverflow.com/questions/37679202
复制相似问题