Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Embedded (base64) images in SVG are not rendered #14348

Closed
astefanutti opened this issue Jun 10, 2016 · 7 comments
Closed

Embedded (base64) images in SVG are not rendered #14348

astefanutti opened this issue Jun 10, 2016 · 7 comments
Labels

Comments

@astefanutti
Copy link
Contributor

  1. Which version of PhantomJS are you using? Tip: run phantomjs --version.

    2.2.0-development

  2. What steps will reproduce the problem?

    1. Run phantomjs examples/rasterize.js test.html test.pdf
    2. with the following test.html document:
    <html>
      <body>
        <img src="test.svg"/>
      </body>
    </html>
    

    and the following test.svg:

    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
            "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <svg height="68px" width="61px" version="1.1"
         xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink">
        <image xlink:href="data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV8AAF9fX8swMNgTAFlDOICAgPNSUnNWSMQ5MBAQEJE3QPIGAM9AQMqGcG9vb6MhJsEdGM8vLx8fH98AANIWAMuQeL8fABkTEPPQ0OM5OSYdGFl5jo+Pj/+pqcsTE78wMFNGQLYmID4dGPvd3UBAQJmTkP+8vH9QUK+vr8ZWSHpzcJMmILdwcLOGcHRQUHxwcK9PT9DQ0O/v70w5MLypoG8wKOuwsP/g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5ZkSqIDaZBV6aSGYq/lGZplndkckZ98xoICbTcIJGQAZcNmdmUc210hs35nCyJ58fgmIKX5RQGOZowxaZwYA+JaoKQwswGijBV4C6SiTUmpphMspJx9unX4KaimjDv9aaXOEBteBqmuuxgEHoLX6Kqx+yXqqBANsgCtit4FWQAEkrNbpq7HSOmtwag5w57GrmlJBASEU18ADjUYb3ADTinIttsgSB1oJFfA63bduimuqKB1keqwUhoCSK374wbujvOSu4QG6UvxBRydcpKsav++Ca6G8A6Pr1x2kVMyHwsVxUALDq/krnrhPSOzXG1lUTIoffqGR7Goi2MAxbv6O2kEG56I7CSlRsEFKFVyovDJoIRTg7sugNRDGqCJzJgcKE0ywc0ELm6KBCCJo8DIPFeCWNGcyqNFE06ToAfV0HBRgxsvLThHn1oddQMrXj5DyAQgjEHSAJMWZwS3HPxT/QMbabI/iBCliMLEJKX2EEkomBAUCxRi42VDADxyTYDVogV+wSChqmKxEKCDAYFDFj4OmwbY7bDGdBhtrnTQYOigeChUmc1K3QTnAUfEgGFgAWt88hKA6aCRIXhxnQ1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==" x="0" y="0" height="68px" width="61px"/>
    </svg>
    

    The embedded image element does not render when the page is exported to PDF or PNG while it renders fine when test.html is opened in a Web browser (tested with Safari and Chrome).

  3. Which operating system are you using?

    Mac OS X

  4. Did you use binary PhantomJS or did you compile it from source?

    Compiled from source @6090f54

  5. Please provide any additional information below.

    Surprisingly, the embedded image does render with the following page:

    <html>
      <body>
        <img src="test.svg"/>
        <object data="test.svg"/>
      </body>
    </html>
    

    That is the corresponding image is rendered twice.

@robinfhu
Copy link

+1. I encountered the same issue using PhantomJS build 2.1.1, on Mac OSX.

@abulgatz
Copy link

abulgatz commented Dec 28, 2016

Exact same problem. SVG renders fine in chrome, and if I use phantomjs to go straight from SVG to PNG, the embedded base64 encoded png renders fine. But If I embed the SVG in an HTML page and attempt to go from HTML to PDF, the SVG is missing its embedded PNG background.

OS X 10.11 with phantomJS 2.1.1

@GoldHornKing
Copy link

+1

@GoldHornKing
Copy link

GoldHornKing commented Feb 23, 2017

PDF from this HTML will get svg rendered

<html>
  <body>
    <object data="test.svg"/>
  </body>
</html>

PDF from this HTML will not have image

<html>
  <body>
    <img src="test.svg"/>
  </body>
</html>

PDF from this HTML will have two images

<html>
  <body>
    <img src="test.svg"/>
    <object data="test.svg"/>
  </body>
</html>

@kashesandr
Copy link

kashesandr commented Sep 21, 2017

Phantomjs doesn't render element with background like this:
domElement.setAttribute('style', "background: transparent url(\"data:image/svg+xml;utf8,<svg...")

MacOs Sierra 10.12.6
phantomjs 2.1.1

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
@stefjoosten
Copy link

According to Mozilla's SVG documentation, the data URL's in SVG only support JPEG, PNG and other SVG's , so I would expect xlink:href="data:image/gif... not to work.

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

No branches or pull requests

6 participants