Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
85 posts
|
If I include a diagram by URL reference, the HTML generates properly (as one would expect).
The PDF does not; the reference is just output in its literal form. Should the PDF generator know how to do the inclusion? Or do I need to make a static copy of the diagram (which may change at source...) and save that, and then reference it locally to get it in the PDF? - thomas |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
Thomas, As you know, PDF is a self-contained format, so all resources must be embedded into it at build time. The HTML works because HTML can just link to the asset. So, yes, the PDF generator needs to download these resources from the internet. Asciidoctor supports automatically downloading resources from the internet to embed them into the document. However, this feature is "hidden" behind a security flag. You need to enable the allow-uri-read attribute from the CLI or API. $ asciidoctor-pdf -a allow-uri-read document.adoc To avoid slowing down the build, you can enable the (very primitive) URI cache. $ gem install open-uri-cached Then you can enable the URI cache: $ asciidoctor-pdf -a allow-uri-read -a cache-uri document.adoc The cache is stored in /tmp/open-uri-{uid}. Cheers, -Dan On Wed, Apr 20, 2016 at 11:34 AM, wolandscat [via Asciidoctor :: Discussion] <[hidden email]> wrote: If I include a diagram by URL reference, the HTML generates properly (as one would expect). Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
85 posts
|
Right. This all makes sense. Thanks for the answer!
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
85 posts
|
In reply to this post by mojavelinux
So far I can't get this to work. I have the following command line (in a script):
run_asciidoctor_pdf () { out_file=${1}.pdf # work out the options opts="-a current_year=$year \ -a stylesdir=$stylesdir \ -a resources_dir=$resources_dir \ -a uml_export_dir=$uml_export_dir \ -a pdf-style=$pdf_theme \ -a pdf-stylesdir=$resources_dir \ -a allow-uri-read -a cache-uri \ -r asciidoctor-pdf -b pdf \ --out-file=$out_file" # -a pdf-fontsdir=path/to/fonts if [ "$pdf_trace" = true ]; then opts="${opts} --trace" fi asciidoctor ${opts} $2 echo generated $(pwd)/$out_file } I just added the line '-a allow-uri-read -a cache-uri' to the previous version. I installed open-uri-cached as above. When I run my script, something happens, because I see this in /tmp (actually in cygwin's /tmp area): /tmp /open-uri-1001 /www.openehr.org # this is indeed the site from which the image comes 8a4608a543e26f1107b8842d250d74f7f86607db 8a4608a543e26f1107b8842d250d74f7f86607db.meta But there is no .png or .svg in /tmp. The source link is to a .svg. The output from running asciidoctor, with trace turned on is: /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/temporary_path.rb:5:in `unlink': No such file or directory @ unlink_internal - /tmp/image-20160421-226964-199iqrn.png (Errno::ENOENT) from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/temporary_path.rb:5:in `unlink' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:2216:in `unlink_tmp_file' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:859:in `convert_image' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:88:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:71:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `block in content' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `map' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `content' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:104:in `convert_content_for_block' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:305:in `convert_section' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:88:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:71:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `block in content' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `map' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb:80:in `content' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/document.rb:1104:in `content' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:104:in `convert_content_for_block' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:149:in `convert_document' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8/lib/asciidoctor-pdf/converter.rb:88:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/document.rb:1044:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor.rb:1503:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:94:in `block in invoke!' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `each' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `invoke!' from /usr/local/gems/asciidoctor-1.5.4/bin/asciidoctor:14:in `<top (required)>' from /home/Thomas/bin/asciidoctor:23:in `load' from /home/Thomas/bin/asciidoctor:23:in `<main>' any ideas? - thomas |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
/usr/local/gems/asciidoctor-pdf-1.5.0.alpha.8 I'm pretty sure this is your problem right here. We're currently on 1.5.0.alpha.11. There was a bug in previous versions with URI reads. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
85 posts
|
That did occur to me about 1 minute after posting.... so with the update, I get this:
/usr/local/gems/ttfunk-1.4.0/lib/ttfunk.rb:34:in `verify_and_open': /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/data/fonts/notoserif-regular-latin.ttf not found (ArgumentError) from /usr/local/gems/ttfunk-1.4.0/lib/ttfunk.rb:13:in `open' from /usr/local/gems/prawn-2.0.1/lib/prawn/font/ttf.rb:351:in `read_ttf_file' from /usr/local/gems/prawn-2.0.1/lib/prawn/font/ttf.rb:27:in `initialize' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:292:in `new' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:292:in `load' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:244:in `find_font' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:58:in `font' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/prawn_ext/extensions.rb:185:in `font' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:1525:in `layout_title_page' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:143:in `convert_document' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:96:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/document.rb:1044:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor.rb:1503:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:94:in `block in invoke!' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `each' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `invoke!' from /usr/local/gems/asciidoctor-1.5.4/bin/asciidoctor:14:in `<top (required)>' from /home/Thomas/bin/asciidoctor:23:in `load' from /home/Thomas/bin/asciidoctor:23:in `<main>' I suspect this means something like a current default font is no longer supported? - thomas |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
We changed the name of the default fonts. A small migration is required. Please compare the font catalog of your custom theme with the default one. Note the font file names. -Dan On Thu, Apr 21, 2016 at 2:58 PM, wolandscat [via Asciidoctor :: Discussion] <[hidden email]> wrote: That did occur to me about 1 minute after posting.... so with the update, I get this:/usr/local/gems/ttfunk-1.4.0/lib/ttfunk.rb:34:in `verify_and_open': /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/data/fonts/notoserif-regular-latin.ttf not found (ArgumentError) from /usr/local/gems/ttfunk-1.4.0/lib/ttfunk.rb:13:in `open' from /usr/local/gems/prawn-2.0.1/lib/prawn/font/ttf.rb:351:in `read_ttf_file' from /usr/local/gems/prawn-2.0.1/lib/prawn/font/ttf.rb:27:in `initialize' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:292:in `new' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:292:in `load' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:244:in `find_font' from /usr/local/gems/prawn-2.0.1/lib/prawn/font.rb:58:in `font' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/prawn_ext/extensions.rb:185:in `font' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:1525:in `layout_title_page' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:143:in `convert_document' from /usr/local/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:96:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/document.rb:1044:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor.rb:1503:in `convert' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:94:in `block in invoke!' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `each' from /usr/local/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/invoker.rb:86:in `invoke!' from /usr/local/gems/asciidoctor-1.5.4/bin/asciidoctor:14:in `<top (required)>' from /home/Thomas/bin/asciidoctor:23:in `load' from /home/Thomas/bin/asciidoctor:23:in `<main>' ... [show rest of quote] Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
85 posts
|
That worked!
That new asciidoctor-pdf version is a *lot* better (syntax colourising works, image inclusion, fonts, text flow ...). But I still see some errors with images. E.g. width=%50 does strange things, some SVGs lose their text, ... shall I report these on the asciidoctor-pdf git tracker? - thomas |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
Great news! wolandscat wrote: E.g. width=%50 does strange things You should always use pdfwidth= for images in PDFs (which you can use along with the width attribute for HTML). The units can be relative (%) or absolute (in, cm, pt, etc) , some SVGs lose their text, 9/10 this is an issue with prawn-svg. See https://github.com/mogest/prawn-svg However, before you report it there, you may want to try using the latest version of prawn-svg, which is not yet installed by default (it will be once we cut a new alpha of asciidoctor-pdf). ... shall I report these on the asciidoctor-pdf git tracker? Aside from what I mentioned, yes. Though, when reporting issues in asciidoctor-pdf, it's best if you first test with the master. See https://github.com/asciidoctor/asciidoctor-pdf#development Cheers, |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
6 posts
|
This post was updated on Oct 01, 2019; 7:58pm.
Hi, I just found this thread, since I was hitting the same issue of not rendering URL referenced images in PDF using the Gradle plugin. Is there a config option in the gradle configuration to enable uri read?
Edit : I found the solution in the mean time. You should add 'allow-uri-read': '' to the attributes of asciidoctor When running a build against PDF backend, the images are rendered in the PDF document |
Free forum by Nabble | Edit this page |