Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

probleme de codage

Status
Not open for further replies.

Maazoul

Programmer
Jul 15, 2004
2
TN
bonjour tout le monde,je suis nouveau sur ce site que je juge a priori formidable..et je serai vraiment reconnaissant si vous me trouverez des reponses et des solutions aux problemes que j'ai eu avec xml/xsl
bref, je dois generer en format pdf des etats bien determiner en deux versions : francaise et arabe....
en ce qui concerne la langue francaise ca marche bien
alors qu'en arabe je n'arrive plus a afficher les texts ecris en arbae (xsl)
j'ai essayé le (encoding="UTF_8" ) dans les fichiers xml,xsl,xsd mais le convertisseur que j'utilise (ecris en java) de (xml/xsl) vers pdf me genere des problemes comme s'il ne reconnais pas ce codage.....
Que dois-je faire????
merci d'avance
 
For those who find French even more challenging then xsl:
Maazoul wants to generate .pdf-output in French as well as in Arabic. French works OK, but he can't render text written in Arab. He tryed to put in a 'encoding="UTF_8"' in his xml-, xsl- and xsd-files. he uses a Java-parser (not specified which one) to generate the pdf. This parser 'generates some problems like it doesn't recognise the encoding'.

Mazoul: je n'ai aucun d'idee, mais peut-etre il y a quelque'un qui a utilise la meme convertisseur... Comment s'appele?
 
ok thanks a lot for replying me(my english isn't so good!)!
i willl tell you exactly what i'm using to generate pdf:
In fact i started my application by using this java code to transform my xml/xsl document into pdf file:

Code:
package xml2pdf;
//Java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

//JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;

//Avalon
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;

//FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.messaging.MessageHandler;

/**
 * This class demonstrates the conversion of an XML file to PDF using 
 * JAXP (XSLT) and FOP (XSL:FO).
 */
public class ExampleXML2PDF {

    public void convertXML2PDF(File xml, File xslt, File pdf) 
                throws IOException, FOPException, TransformerException {
        //Construct driver
        Driver driver = new Driver();
        
        //Setup logger
        Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
        driver.setLogger(logger);
        MessageHandler.setScreenLogger(logger);

        //Setup Renderer (output format)        
        driver.setRenderer(Driver.RENDER_PDF);
        
        //Setup output
        OutputStream out = new java.io.FileOutputStream(pdf);
        try {
            driver.setOutputStream(out);

            //Setup XSLT
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new StreamSource(xslt));
        
            //Setup input for XSLT transformation
            Source src = new StreamSource(xml);
        
            //Resulting SAX events (the generated FO) must be piped through to FOP
            Result res = new SAXResult(driver.getContentHandler());

            //Start XSLT transformation and FOP processing
            transformer.transform(src, res);
        } finally {
            out.close();
        }
    }


    public static void main(String[] args) {
        try {
            System.out.println("FOP ExampleXML2PDF\n");
            System.out.println("Preparing...");

            //Setup directories
            File baseDir = new File("xml2pdf");
            File outDir = new File(baseDir, "out");
            outDir.mkdirs();

            //Setup input and output files            
						getFile xmlFile =new getFile();
            File xmlfile = new File(xmlFile.getFilePath());//(baseDir,"xml/xml/Etat_Cout_Revient_Activite.xml");
						File xsltfile = new File(new getFile().getFilePath());//(baseDir,"xml/xslt/Etat_Cout_Revient_Activite.xsl");
            File pdffile = new File(outDir,xmlFile.getName()+".pdf");

            System.out.println("Input: XML (" + xmlfile + ")");
            System.out.println("Stylesheet: " + xsltfile);
            System.out.println("Output: PDF (" + pdffile + ")");
            System.out.println();
            System.out.println("Transforming...");
            
            ExampleXML2PDF app = new ExampleXML2PDF();
            app.convertXML2PDF(xmlfile, xsltfile, pdffile);
            
            System.out.println("Success!");
        } catch (Exception e) {
            System.err.println(ExceptionUtil.printStackTrace(e));
            System.exit(-1);
        }
    }
}
but arabic character appears like ####


After that i have thought to an xml config so i have tryed the fop-0.20.5 to do the conversion
and i have added a file configuration xml which is:
Code:
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<!-- to developers: have a look at the config.dtd to 
     see how to structure your config entries -->

<configuration>
  <entry>
    <key>version</key>
    <value>FOP @version@</value>
  </entry>

  <!-- default values for commandline options -->
  <!-- suppress all progress information, error message are still displayed -->
  <entry>
    <key>quiet</key>
    <value>false</value>
  </entry>
<!-- sets debug mode on/off; debug mode hasm more progress 
     information and a stacktrace in case of a fatal exception -->
  <entry>
    <key>debugMode</key>
    <value>false</value>
  </entry>
  <!-- displays all configuration  settings and then exits -->
  <entry>
    <key>dumpConfiguration</key>
    <value>false</value>
  </entry>

  <!-- stream-filter-list provides the default filters that are applied to all
       stream objects within the PDF file. These are normally used for 
       compression -->
  <entry role="pdf">
    <key>stream-filter-list</key>
    <list>
      <!-- provides compression using zlib flate (default is on)-->
      <value>flate</value>
      
      <!-- encodes binary data into printable ascii characters (default off)
           This provides about a 4:5 expansion of data size -->
      <value>ascii-85</value>

      <!-- encodes binary data with hex representation (default off)
           This filter is not recommended as it doubles the data size -->
      <!-- <value>ascii-hex</value> -->
    </list>
  </entry>
  <fonts>
  </fonts>
</configuration>


because i m using the font-family="ArialUnicodeMS".
so in cmd i wrote something like that:
c:\fop -c userconfig.xml -xml file.xml -xsl file.xsl -pdf file.pdf
but i still having problems !
arabic letters appears like ##### in pdf file.
NB: i use adobe acrobat professional 6.0
thanks a lot.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top