Results 1 to 2 of 2
  1. #1
    simsu123 is offline Member
    Join Date
    Jun 2010
    Posts
    1
    Rep Power
    0

    Question XHTML to FO Transformation Issue for Special Characters

    Hi

    AppServer: WebSphere 6.1
    Character Set : UTF8

    I have a PDFService Class that generates PDF files considering HTML data. Html data contains special characters such as à €.
    The HTML to xHTML transformation happens correctly and shows proper data. But xHTML to OutputStream transformation has issues and shows all "???" instead of valid characters.

    Given below is the code.
    System output from Tidy gives proper values.
    But after it is converted to ByteArrayStream, the output does not come properly in the second System Output.





    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    import org.apache.fop.apps.Driver;
    import org.apache.fop.apps.FOPException;
    import org.htmlparser.util.Translate;
    import org.w3c.dom.*;
    import org.w3c.tidy.Tidy;
    import org.xml.sax.InputSource;

    String xhtml = outXhtml.toString();
    xhtml = " à test è test  ";
    System.out.println("xhtml from Tidy >>>"+xhtml);

    int nEndDocType = xhtml.indexOf('>');
    xhtml = "<!DOCTYPE html SYSTEM \n \"" + Config.web_root.replace('\\', '/') + "/xslt/xhtml1-transitional.dtd\">" + xhtml.substring(nEndDocType + 1);

    ByteArrayInputStream inXHtml = new ByteArrayInputStream(xhtml.getBytes());

    ByteArrayOutputStream outXF = new ByteArrayOutputStream();
    BufferedOutputStream boutXF = new java.io.BufferedOutputStream(outXF);

    StreamSource streamInHtml = new StreamSource();
    streamInHtml.setInputStream(inXHtml);

    StreamResult streamOutXF = new StreamResult();
    streamOutXF.setOutputStream(boutXF);

    transformer.transform(streamInHtml, streamOutXF);
    timeGenXslFO = watch.elapsed();

    String xslFO = outXF.toString();
    System.out.println("xslFO from transformer >>>"+xslFO);

    Driver driver = new Driver();
    driver.setRenderer(1);
    s22 = Translate.decode(s22);
    driver.setInputSource(new InputSource(new ByteArrayInputStream(s22.getBytes())));
    driver.setOutputStream(((OutputStream) (obj)));
    driver.run();
    l9 = stopwatch.elapsed();
    ((OutputStream) (obj)).close();
    break MISSING_BLOCK_LABEL_2430;
    Object obj1;
    obj1;
    System.out.println((new StringBuilder()).append("FOP Exception: ").append(((FOPException) (obj1)).getMessage()).toString());
    l10 = stopwatch.elapsed();
    ((OutputStream) (obj)).close();
    break MISSING_BLOCK_LABEL_2430;
    obj1;
    Log.writeln(((Exception) (obj1)));
    l10 = stopwatch.elapsed();
    ((OutputStream) (obj)).close();
    break MISSING_BLOCK_LABEL_2430;
    Exception exception1;
    exception1;
    ((OutputStream) (obj)).close();
    throw exception1;
    Exception exception;
    exception;
    Log.writeln(exception);
    l10 = stopwatch.elapsed();

    return;




    Can anybody pls help me to understand why this issue occurs and if there is any solution/alternative for conversion to PDF.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,890
    Rep Power
    25

    Default

    Do you have a small program that compiles and executes and the needed input to test with?

    Somewhere you're not giving the correct encoding and you get ???? output.
    Several methods/constructors take encodings/charset as an argument.

Similar Threads

  1. XML with special characters
    By Kaizah in forum XML
    Replies: 1
    Last Post: 11-06-2009, 03:26 PM
  2. [SOLVED] special characters (ASCII)
    By AlejandroPe in forum New To Java
    Replies: 8
    Last Post: 04-06-2009, 11:42 AM
  3. Searching for Microsoft special characters
    By Tim McDaniel in forum Eclipse
    Replies: 2
    Last Post: 02-24-2009, 04:11 PM
  4. special characters
    By ravian in forum New To Java
    Replies: 2
    Last Post: 11-16-2007, 02:28 PM
  5. Special characters in text fields
    By Felissa in forum Web Frameworks
    Replies: 0
    Last Post: 06-27-2007, 05:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •