Results 1 to 2 of 2
- 06-29-2010, 11:42 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
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.
- 06-30-2010, 12:04 AM #2
Similar Threads
-
XML with special characters
By Kaizah in forum XMLReplies: 1Last Post: 11-06-2009, 02:26 PM -
[SOLVED] special characters (ASCII) åäö
By AlejandroPe in forum New To JavaReplies: 8Last Post: 04-06-2009, 10:42 AM -
Searching for Microsoft special characters
By Tim McDaniel in forum EclipseReplies: 2Last Post: 02-24-2009, 03:11 PM -
special characters
By ravian in forum New To JavaReplies: 2Last Post: 11-16-2007, 01:28 PM -
Special characters in text fields
By Felissa in forum Web FrameworksReplies: 0Last Post: 06-27-2007, 04:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks