with color code archivo svg png transcoding batik

code - svg to png with color



El texto de SVG a PNG no se muestra correctamente-Fuente Arial (1)

Estoy teniendo un problema de PNG convertido usando Apache Batik es diferente cuando hay un texto con diferentes fuentes de la familia, como Arial. El problema ocurre en el entorno donde Cent OS 6 ejecuta Tomcat 7 y Java 6.

El código de Java utilizado para convertir SVG a PNG es:

// Convert the SVG image to png and send back PNGTranscoder transcoder = new PNGTranscoder(); // TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgImage)); outStream = new ByteArrayOutputStream(); TranscoderOutput output = new TranscoderOutput(outStream); // Transcode the given SVG transcoder.transcode(input, output); outStream.flush(); pngImage = outStream.toByteArray();

El archivo SVG que voy a convertir a PNG es:

<svg version="1.1" x="0" y="0" id="hjtqebzv1" width="610" height="240" xmlns="http://www.w3.org/2000/svg" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <linearGradient id="LFFFFFF0" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" style="stop-color:#FFFFFF;stop-opacity:0.8"/> <stop offset="100%" style="stop-color:#FAFAFA;stop-opacity:1"/> </linearGradient> </defs> <g id="hjtqebzv-o1" transform="translate(5,5)"> <rect x="1" y="1" width="578" height="20" fill="url(#LFFFFFF0)" stroke="#5e5ca7" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/> <text x="1" y="1" width="578" height="19" > <tspan x="2" y="14" style="font-family:Arial;font-size:12px;fill:#000000;">This is a test text for testing text overlapping in the rectangle when convert the svg to PNG using SVG-Batik</tspan> </text> </g> </svg>

Cuando abro el archivo SVG en el navegador Firefox se muestra correctamente como se indica en la imagen siguiente:

Pero cuando convierto el SVG usando Apache Batik, la imagen convertida se ve diferente. El Apache Batik convertido PNG es:

En Windows 7 ejecutando Tomcat 7 y Java 7, la imagen generada es idéntica a la SVG original.

Como el servidor Cent OS da la imagen de texto alterada, siento que la fuente Arial no está disponible para la aplicación tomcat / java y necesito cargarla manualmente. Si es así, prefiero tener un consejo para cargarlos de una manera común desde la ubicación del sistema operativo subyacente (ubicación de la fuente del sistema operativo) sin ningún cambio en el archivo SVG.


JAVA_FONTS instalar las fuentes truetype de Microsoft y ponerlas a disposición de la máquina virtual Java estableciendo la variable de entorno JAVA_FONTS .

wget http://www.my-guides.net/en/images/stories/fedora12/msttcore-fonts-2.0-3.noarch.rpm rpm -ivh msttcore-fonts-2.0-3.noarch.rpm

Abra /etc/bashrc y agregue siguiente al final del archivo

JAVA_FONTS=/usr/share/fonts/msttcore export JAVA_FONTS

http://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-microsoft-truetype-fonts-in-centos-6-rhel-6.html#axzz2aibHZaOI