Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SVG images fail to convert linear gradients #228

Closed
wolandscat opened this issue Jun 24, 2015 · 9 comments · Fixed by #796
Closed

SVG images fail to convert linear gradients #228

wolandscat opened this issue Jun 24, 2015 · 9 comments · Fixed by #796
Assignees
Labels

Comments

@wolandscat
Copy link

When I convert my document to using .svg images generated from a UML tool, I get this, for each one:

asciidoctor: WARNING: could not embed image: /cygdrive/c/dev/openEHR/spec-publish-asciidoc/source/AOM2/uml_diagrams/AOM-archetype.svg; no implicit conversion of Prawn::Svg::Parser::Image::FakeIO into String

I know the SVGs are fine because they display normally in the HTML-generated output.

The only reference to the problem I could find is here, and this seems old-ish...

Here's one of the .svgs.

Any ideas?

@mojavelinux
Copy link
Member

For reference, here's the correct link to the sample SVG:

https://github.com/openEHR/spec-publish-asciidoc/blob/master/docs/AOM2/uml_diagrams/AOM-archetype.svg

@mojavelinux
Copy link
Member

This looks like a potential incompatibility between the versions of prawn and prawn-svg that you are using. I'm not able to reproduce it yet. To help, could you give me the output of the following commands:

$ gem list

and

$ asciidoctor-pdf -v

Also, keep in mind that these diagrams aren't going to look the way you expect (yet) in Asciidoctor PDF because prawn-svg does not support linear gradients. If there's a way you can disable linear gradients in the output of the UML tool, they are going to look a lot better once inserted.

For the status on the linear gradient support, see mogest/prawn-svg#62

@mojavelinux mojavelinux added this to the support milestone Jun 24, 2015
@wolandscat
Copy link
Author

Sorry about the link - I changed the repo later in the day. I've fixed it in the original report above.

$ gem list

*** LOCAL GEMS ***

addressable (2.3.8)
afm (0.2.2)
Ascii85 (1.0.2)
asciidoctor (1.5.2)
asciidoctor-pdf (1.5.0.alpha.7)
bundler (1.10.4, 1.9.9)
chunky_png (1.3.4)
coderay (1.1.0)
compass (0.12.7)
css_parser (1.3.6)
fssm (0.2.10)
hashery (2.1.1)
io-console (0.4.2)
json (1.8.2)
minitest (5.4.3, 4.7.5)
molinillo (0.2.3)
net-http-persistent (2.9.4)
pdf-core (0.2.5)
pdf-reader (1.3.3)
polyglot (0.3.5)
posix-spawn (0.3.11)
power_assert (0.2.2)
prawn (1.2.1)
prawn-icon (0.6.4)
prawn-svg (0.18.0)
prawn-table (0.1.1)
prawn-templates (0.0.3)
psych (2.0.13)
pygments.rb (0.6.3)
rake (10.4.2)
rdoc (4.2.0)
ruby-rc4 (0.1.5)
safe_yaml (1.0.4)
sass (3.2.19)
test-unit (3.0.8)
thor (0.19.1)
thread_safe (0.3.4)
treetop (1.5.3)
ttfunk (1.2.2)
yajl-ruby (1.2.1)
zurb-foundation (4.3.2)


$ asciidoctor-pdf -v
Asciidoctor 1.5.2 [http://asciidoctor.org]
Runtime Environment (ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-cygwin]) (lc:UTF-8 fs:Windows-1252 in:- ex:UTF-8)

W.r.t. linear gradients I assume you mean the colour gradients? It would be good if colours of some kind are preserved, but gradients is no big deal. We probably can disable them in the tool.

@mojavelinux
Copy link
Member

I see you are using asciidoctor-pdf 1.5.0.alpha.7. Could you try this with 1.5.0.alpha.8? We've upgraded both prawn and prawn-svg since 1.5.0.alpha.7, so this issue is very likely related to the use of these older gems (I recognize things are moving fast right now).

I assume you mean the colour gradients?

That is correct.

It would be good if colours of some kind are preserved, but gradients is no big deal.

You get the underlying color, which is gray. Here's how it looks when I render it with the latest code.

svgs

@wolandscat
Copy link
Author

They certainly are moving. Ok, I did the upgrade (gem upgrade xxx now seems to do everything properly!), and asciidoctor-pdf no longer complains about any files. But what I get as output is pretty close to unreadable:
image

That's me viewing it in the standard Acrobat view on Windows 8. Issues:

  • the 'grey' is too dark to be readable, and seems unrelated to any colours we set in the UML tool (or now looking carefully, I think it may be the grey of the inheritance lines - so the renderer has possibly read the first colour value off some table?)
  • this image is being rendered at some sort of native size and then simply cropped, rather than scaled to fit the page, or even better, scaled to fit a landscape page

We can go back to using PNGs for the moment, where only scaling is an issue (but I saw your other posts about that), so we won't die on this SVG stuff if we can't have it instantly. Progress is obviously occurring, which is good.

@mojavelinux
Copy link
Member

The dark appearance is a result of using prawn-svg 0.20.0. Unfortunately, prawn-svg 0.21.0 came out after the Asciidoctor PDF 1.5.0.alpha.8 release with a fix for this issue. You should be able to upgrade it explicitly and use it. Just type

$ gem update prawn-svg

and it should get you prawn-svg 0.21.0.

The linear gradient feature is being worked so there's hope an even better solution is coming.

this image is being rendered at some sort of native size and then simply cropped, rather than scaled to fit the page, or even better, scaled to fit a landscape page

That's a scenario I didn't see until after the alpha.8 release. For now, you can set the pdfwidth attribute on the image to set a width that only applies to PDF output. Usually a value of 100% will do.

@mojavelinux
Copy link
Member

I'm happy to report that support for linear gradients is making it's way through Prawn and Prawn SVG. We'll continue tracking that progress upstream. Note, however, that no changes are required in Asciidoctor PDF other than upgrading the version of Prawn and Prawn SVG once these features become available.

@mojavelinux mojavelinux changed the title SVG images fail to convert SVG images fail to convert linear gradients Sep 2, 2016
@mojavelinux mojavelinux modified the milestones: v1.5.0, support Sep 2, 2016
@mojavelinux mojavelinux self-assigned this Sep 2, 2016
@mojavelinux
Copy link
Member

I updated the title of this issue to focus on the linear gradient feature. Once that is available in Prawn SVG, we'll upgrade and this issue will be resolved.

Follow the progress at mogest/prawn-svg#62.

@mojavelinux
Copy link
Member

This is now resolved upstream!! You'll be able to use the feature in alpha.16.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
2 participants