Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

data:image/svg+xml;base64,... does not seem to be supported #1423

Closed
xorcus opened this issue Dec 10, 2019 · 6 comments
Closed

data:image/svg+xml;base64,... does not seem to be supported #1423

xorcus opened this issue Dec 10, 2019 · 6 comments
Assignees
Milestone

Comments

@xorcus
Copy link

xorcus commented Dec 10, 2019

Using gradle plugin:

plugins {
  id "org.asciidoctor.jvm.convert" version "2.4.0"
  id "org.asciidoctor.jvm.pdf" version "2.4.0"
}
asciidoctorPdf {
  sourceDir file("asciidoc-src/")
  outputDir file("asciidoc/")
  sources { include "*.adoc" }
  attributes = [
    "imagesdir": file("asciidoc-src/"),
    "allow-uri-read": true
  ]
}

I keep getting the following error as if reading data-uri is not supported:

asciidoctor: WARNING: image to embed not found or not readable: data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld2JveD0iMCAwIDE2IDE2Ij48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0wIDEuNzc3QzAgLjc5Ni43OTYgMCAxLjc3NyAwaDEyLjQ0NkMxNS4yMDQgMCAxNiAuNzk2IDE2IDEuNzc3djEyLjQ0NmMwIC45ODEtLjc5NiAxLjc3Ny0xLjc3NyAxLjc3N0gxLjc3N0ExLjc3OCAxLjc3OCAwIDAgMSAwIDE0LjIyM1YxLjc3N3oiIGZpbGw9IiNGRjU2MzAiLz48Y2lyY2xlIGZpbGw9IiNGRkYiIGN4PSI4IiBjeT0iOCIgcj0iNCIvPjwvZz48L3N2Zz4=

In place of the image, the generated PDF shows:

[svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3Ln
czLm9yZy8yMDAwL3N2ZyIgdmlld2JveD0iMCAwIDE2IDE2Ij48ZyBmaWxsPSJub25lIiBmaWxsLXJ
1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0wIDEuNzc3QzAgLjc5Ni43OTYgMCAxLjc3NyAwaDEyLj
Q0NkMxNS4yMDQgMCAxNiAuNzk2IDE2IDEuNzc3djEyLjQ0NmMwIC45ODEtLjc5NiAxLjc3Ny0x
Ljc3NyAxLjc3N0gxLjc3N0ExLjc3OCAxLjc3OCAwIDAgMSAwIDE0LjIyM1YxLjc3N3oiIGZpbGw9Ii
MzNkIzN0UiLz48cGF0aCBkPSJNNC41IDEyLjVWNC4zNzhjMC0uNDg1LjM5Mi0uODc4Ljg3NS0uO
Dc4aDUuMjVjLjQ4MyAwIC44NzUuMzkzLjg3NS44NzhWMTIuNUw4IDguOTg4IDQuNSAxMi41eiI
gZmlsbD0iI0ZGRiIvPjwvZz48L3N2Zz4=]

As a workaround, I could extract the image data and write it to a temporary file, but that is not very convenient for me. Note that the use of image data-uri's in .adoc works as expected when generating HTML output. In both cases, .adoc file has :data-uri:

@mojavelinux
Copy link
Member

It looks like the data URI scheme isn't support for SVGs. The fix seems simple, so I'll plan to add it in the next release. Thanks for reporting!

@mojavelinux mojavelinux self-assigned this Dec 10, 2019
@mojavelinux mojavelinux added this to the v1.5.0 milestone Dec 10, 2019
@xorcus
Copy link
Author

xorcus commented Dec 10, 2019

Thanks for quick response!
I confirm everything works fine with data-uri holding a PNG image. For example:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHXRFWHRqaXJhLXN5c3RlbS1pbWFnZS10eXBlAGF2YXRhcuQCGmEAAACBSURBVHjaY/gfblDwP8zgMxD/JxF/BullIFMz3BAGCjSDMY0MKAv////80f//37/5///Lp///r57+/78iikgDQJq/f/2PAf78+f+/OpYIAy6d+I8TXD9HhAEgZ+MCIO/Q3gCKvUBxIMIMAbnk03uIs0E2Y9FMw4REogEUZiYKszMA1KjMMJgNdpgAAAAASUVORK5CYII=

mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Dec 12, 2019
@saurabhsingh-pvips
Copy link

How do I install the version updated after this commit? I've installed asciidoctor-pdf using gem install asciidoctor-pdf --pre but the error mentioned in the thread is not fixed.

Error Code: asciidoctor: WARNING: allow-uri-read is not enabled; cannot embed remote image: data:image/svg+xml;

Or the above command still points to package that doesn't include the fix yet?
Version used:

Asciidoctor PDF 1.5.0.beta.8 using Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

@mojavelinux
Copy link
Member

The issue labels the version in which the issue is fixed. If that version is not yet available on rubygems.org, then the fix is only in the development tree (aka master). It's marked as 1.5.0 and 1.5.0 has not been released. (Though likely it will get moved to a beta or release candidate).

The contributing guide describes how to install the gem from the development tree. See https://github.com/asciidoctor/asciidoctor-pdf/blob/master/CONTRIBUTING-CODE.adoc#development

@tmeckel
Copy link

tmeckel commented Apr 28, 2023

Used asciidoctor/docker-asciidoctor:latest for converting a document containing a SVG with embedded images, and the error ist still present:

asciidoctor: WARNING: problem encountered in image: /documents/sample.svg; Error retrieving URL data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d
...

@mojavelinux
Copy link
Member

The encoded data you provided is not a complete SVG. I assure you that if the encoded data is a valid SVG, it will work when using Asciidoctor PDF 2.3.x. If you need help using Asciidoctor PDF, please ask in the community chat at https://chat.asciidoctor.org. The issue tracker is not a support portal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants