xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frédéric Lanic <frederic.la...@syselog.com>
Subject Tranform SVG to JPEG, font problem with text
Date Mon, 06 Sep 2004 08:34:37 GMT
I'm using the code from the official web site to tranform SVG to JPEG. The image is convert
very well, but there are some troubles with the text, especially, with the accent.
I see in the SVG file, that the caracter is written in UTF8 type.
I'm using for that : xercesImpl-2.4.0.jar, xml-apis.jar and batik-all-1.5.jar

If anybody have an answer, I will be happy to receive it. I'm a little lost.
I could send you any exemple to show you the trouble. I can't send zip file and my image file
are to biggest with this forum

here's, my code : 
public static String getJpg(ExpressionContext myProcessor, String repTravail, String filePath,
String qualite)
  //public static String getJpg(String repTravail, String filePath, String qualite)
    System.out.println("->getJpg('" + repTravail + "','" + filePath + "','" + qualite +
    // Le fichier source
    filePath = repTravail + filePath;
    File f = null;

    // Si c'est deja du Jpeg ou Gif, alors rien a faire. (FOP les accepte)
    if (filePath.toLowerCase().endsWith(".jpg") ||
      f = new File(filePath);
      if (f.exists()) {
        return filePath;
      else {
        System.err.println("Fichier '" + filePath + "' introuvable !");
        return "";
    //Sinon, on essaye de la convertir en JPG.
    String imgDest = filePath + ".jpg";

    // Génération image
    JPEGTranscoder t = new JPEGTranscoder();

    t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,new Float(Float.parseFloat(qualite)));

    // 96dpi
    //float mult=0.2645833f;
    //t.addTranscodingHint(Transcoder. KEY_PIXEL_TO_MM, new Float(mult));

    // 72dpi
    //float mult=0.3528f;
    //t.addTranscodingHint(JPEGTranscoder.KEY_PIXEL_TO_MM, new Float(mult));

    System.out.println("MULT="+new Float(mult));
    float larg=Float.parseFloat(largeur)*10;
    System.out.println("LARG="+new Float(larg));
    Integer pixLarg=new Integer(new Float(mult*larg).intValue());
    System.out.println("Pixel Largeur ='"+pixLarg.toString()+"'");

    //t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH,new Integer(200));
    FileReader filereader = null;
    OutputStream ostream = null;
    TranscoderInput input = null;
    TranscoderOutput output = null;
    try {
      filereader = new FileReader(filePath);
      input = new TranscoderInput(filereader);
      ostream = new FileOutputStream(imgDest);
      output = new TranscoderOutput(ostream);
      t.transcode(input, output);
      return imgDest;
    } catch (Exception e) {
      System.err.println("Error Transcode SVG->JPG '" + e.toString() + "'");
      return "";
View raw message