Use vml2svg.xsl and its dependencies as the imported stylesheet for the object that calls transformToXML to convert VML to SVG and then convert SVG to PNG using readImageBlob and imagemagick:
<?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/2000/svg" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" > <xsl:variable name="n-elementi"> <xsl:value-of select="count(//*)" /> </xsl:variable> <xsl:variable name="schermo-x"> <xsl:text>750</xsl:text> </xsl:variable> <xsl:variable name="schermo-y"> <xsl:text>400</xsl:text> </xsl:variable> <xsl:template match="/"> <svg preserveAspectRatio="none" overflow="visible"> <xsl:for-each select="//html:BODY | //html:body"> <defs> <xsl:call-template name="gestione-textpath" /> <xsl:call-template name="gestione-gradient" /> <xsl:call-template name="gestione-pattern" /> </defs> <xsl:apply-templates /> </xsl:for-each> </svg> </xsl:template> <xsl:template match="v:group"> <svg> <xsl:call-template name="core-attrs" /> <xsl:call-template name="attributo-viewbox" /> <xsl:attribute name="overflow"><xsl:text>visible</xsl:text></xsl:attribute> <xsl:call-template name="attributo-title" /> <xsl:variable name="r"> <xsl:call-template name="attributo-rotation" /> </xsl:variable> <xsl:variable name="v-coordsize"> <xsl:call-template name="valore-coordsize" /> </xsl:variable> <xsl:variable name="vb_x"> <xsl:value-of select="substring-before(normalize-space($v-coordsize),' ')" /> </xsl:variable> <xsl:variable name="vb_y"> <xsl:value-of select="substring-after(normalize-space($v-coordsize),' ')" /> </xsl:variable> <xsl:choose> <xsl:when test="$r != '0'"> <g> <xsl:attribute name="transform"> <xsl:text>rotate(</xsl:text> <xsl:value-of select="$r" /> <xsl:text>, </xsl:text> <xsl:value-of select="($vb_x div 2)" /> <xsl:text>, </xsl:text> <xsl:value-of select="($vb_y div 2)" /> <xsl:text>)</xsl:text> </xsl:attribute> <xsl:apply-templates /> </g> </xsl:when> <xsl:otherwise> <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </svg> </xsl:template> <xsl:template match="v:shape"> <xsl:variable name="id-of-shapetype"> <xsl:value-of select="substring-after(@type,'#')" /> </xsl:variable> <xsl:variable name="image_present"> <xsl:choose> <xsl:when test="(//v:shapetype[@id = $id-of-shapetype]/v:imagedata) or (v:imagedata)" ><xsl:text>yes</xsl:text></xsl:when> <xsl:otherwise><xsl:text></xsl:text></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="no-fill"> <xsl:choose> <xsl:when test="$image_present = 'yes'"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:when test="v:path[@fillok = 'true']"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="v:path[@fillok = 'false']"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:when test="(//v:shapetype[@id = $id-of-shapetype]/v:path[@fillok = 'true'])"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="(//v:shapetype[@id = $id-of-shapetype]/v:path[@fillok = 'false'])"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text></xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="no-stroke"> <xsl:choose> <xsl:when test="v:path[@strokeok = 'true']"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="v:path[@strokeok = 'false']"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:when test="(//v:shapetype[@id = $id-of-shapetype]/v:path[@strokeok = 'true'])"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="(//v:shapetype[@id = $id-of-shapetype]/v:path[@strokeok = 'false'])"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text></xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <svg> <xsl:call-template name="core-attrs" /> <xsl:choose> <xsl:when test="@coordsize"> <xsl:call-template name="attributo-viewbox" /> </xsl:when> <xsl:when test="//v:shapetype[@id = $id-of-shapetype]"> <xsl:for-each select="//v:shapetype[@id = $id-of-shapetype]"> <xsl:call-template name="attributo-viewbox" /> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:call-template name="attributo-viewbox" /> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="//v:shapetype[@id = $id-of-shapetype]"> <xsl:for-each select="//v:shapetype[@id = $id-of-shapetype]"> <xsl:call-template name="attributi-paint"> <xsl:with-param name="no-fill"> <xsl:value-of select="$image_present" /> </xsl:with-param> </xsl:call-template> </xsl:for-each> <xsl:call-template name="attributi-paint"> <xsl:with-param name="default"> <xsl:text>no</xsl:text> </xsl:with-param> <xsl:with-param name="no-fill"> <xsl:value-of select="$no-fill" /> </xsl:with-param> <xsl:with-param name="no-stroke"> <xsl:value-of select="$no-stroke" /> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="attributi-paint"> <xsl:with-param name="no-fill"> <xsl:value-of select="$no-fill" /> </xsl:with-param> <xsl:with-param name="no-stroke"> <xsl:value-of select="$no-stroke" /> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> <xsl:attribute name="fill-rule"> <xsl:text>evenodd</xsl:text> </xsl:attribute> <xsl:call-template name="attributo-title" /> <xsl:variable name="r"> <xsl:call-template name="attributo-rotation" /> </xsl:variable> <xsl:choose> <xsl:when test="$r != '0'"> <g> <xsl:variable name="cs-w"> <xsl:call-template name="valore-coordsize"> <xsl:with-param name="parametro"><xsl:text>w</xsl:text> </xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="cs-h"> <xsl:call-template name="valore-coordsize"> <xsl:with-param name="parametro"><xsl:text>h</xsl:text> </xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:attribute name="transform"> <xsl:text>rotate(</xsl:text> <xsl:value-of select="$r" /> <xsl:text>, </xsl:text> <xsl:value-of select="($cs-w div 2)" /> <xsl:text>, </xsl:text> <xsl:value-of select="($cs-h div 2)" /> <xsl:text>)</xsl:text> </xsl:attribute> <xsl:call-template name="gestione-href"> <xsl:with-param name="nome-template"> <xsl:text>vml-shape</xsl:text> </xsl:with-param> </xsl:call-template> </g> </xsl:when> <xsl:otherwise> <xsl:call-template name="gestione-href"> <xsl:with-param name="nome-template"> <xsl:text>vml-shape</xsl:text> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </svg> </xsl:template> <xsl:template name="vml-shape"> <xsl:variable name="id-of-shapetype"> <xsl:value-of select="substring-after(@type,'#')" /> </xsl:variable> <xsl:variable name="aggiustamento"> <xsl:for-each select="v:*"> <xsl:if test="position() = last()"> <xsl:call-template name="calcola-scala" /> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:for-each select="//v:shapetype[@id = $id-of-shapetype]/v:imagedata"> <xsl:call-template name="elemento-imagedata" /> </xsl:for-each> <xsl:for-each select="v:imagedata"> <xsl:call-template name="elemento-imagedata" /> </xsl:for-each> <xsl:choose> <xsl:when test="((v:path[@textpathok = 'true' or @textpathok = 't']) or (//v:shapetype[@id = $id-of-shapetype]/v:path [@textpathok = 'true' or @textpathok = 't'])) and ((v:textpath) or (//v:shapetype[@id = $id-of-shapetype]/v:textpath))"> <xsl:choose> <xsl:when test="v:textpath[@string]"> <xsl:for-each select="v:textpath[@string]"> <xsl:if test="position() = last()"> <xsl:call-template name="elemento-textpath" /> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="v:textpath"> <xsl:variable name="stringa-st"> <xsl:for-each select=" //v:shapetype[@id = $id-of-shapetype]/ v:textpath[@string]"> <xsl:if test="position() = last()"> <xsl:value-of select="@string" /> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:for-each select="v:textpath"> <xsl:if test="position() = last()"> <xsl:call-template name="elemento-textpath" > <xsl:with-param name="stringa"> <xsl:value-of select="$stringa-st" /> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="//v:shapetype[@id = $id-of-shapetype]/v:textpath"> <xsl:variable name="path-id"> <xsl:choose> <xsl:when test="v:path[@v != ''] or @path != ''"> <xsl:value-of select="count(preceding::v:*) + count(ancestor::v:*)" /> </xsl:when> <xsl:otherwise> <xsl:text></xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:for-each select=" //v:shapetype[@id = $id-of-shapetype]/v:textpath"> <xsl:if test="position() = last()"> <xsl:choose> <xsl:when test="$path-id = ''"> <xsl:call-template name="elemento-textpath"> <xsl:with-param name="aggiustamento"> <xsl:value-of select="$aggiustamento" /> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="elemento-textpath" > <xsl:with-param name="path-id"> <xsl:value-of select="$path-id" /> </xsl:with-param> <xsl:with-param name="aggiustamento"> <xsl:value-of select="$aggiustamento" /> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <XXX></XXX> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="v:path[@v != '']"> <xsl:for-each select="v:path[@v != '']"> <xsl:if test="position() = last()"> <xsl:call-template name="gestione-path" /> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="@path != ''"> <xsl:call-template name="elemento-path"> <xsl:with-param name="v"> <xsl:value-of select="@path" /> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:for-each select="//v:shapetype[@id = $id-of-shapetype]"> <xsl:choose> <xsl:when test="v:path[@v != '']"> <xsl:for-each select="v:path[@v != '']"> <xsl:if test="position() = last()"> <xsl:call-template name="gestione-path" /> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="@path != ''"> <xsl:call-template name="elemento-path"> <xsl:with-param name="v"> <xsl:value-of select="@path" /> </xsl:with-param> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:otherwise> </xsl:choose> <xsl:if test="(v:textbox)"> <xsl:call-template name="elemento-textbox"> <xsl:with-param name="id-of-shapetype"> <xsl:value-of select="$id-of-shapetype" /> </xsl:with-param> <xsl:with-param name="aggiustamento"> <xsl:value-of select="$aggiustamento" /> </xsl:with-param> </xsl:call-template> </xsl:if> <xsl:apply-templates /> </xsl:template> <xsl:template name="elemento-shapetype"> </xsl:template> <xsl:template name="gestione-shapetype"> </xsl:template> <xsl:template match="html:a"> <xsl:choose> <xsl:when test="@href"> <a> <xsl:attribute name="xlink:href"> <xsl:value-of select="@href" /> </xsl:attribute> <xsl:apply-templates /> </a> </xsl:when> <xsl:otherwise> <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template>
source share