You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Michael Niemann <xm...@yahoo.com> on 2007/11/12 12:07:27 UTC
Character encoding problem
Hello,
I've read quite a few older postings about encodig problems and mine might not be connected to FOP directly.
I pass two streams to FOP. The xslt stream includes the output tag with its encoding set to UTF-8 but still the resulting pdf doesn't show the german Umlaute correctly.
I'm using the following code to call the transformer. The method get both the XML and XSLT as Strings via the parameters xmlinput and xsltinput:
InputStream xmlin = new ByteArrayInputStream(xmlinput.getBytes());
InputStream xsltin = new ByteArrayInputStream(xsltinput.getBytes());
out = new ByteArrayOutputStream();
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
try {
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltin));
transformer.setOutputProperty("encoding", "UTF-8");
Source src = new StreamSource(xmlin);
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
....
Is there some setting I am missing?
regards
Michael.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Character encoding problem
Posted by Chris Bowditch <bo...@hotmail.com>.
Michael Niemann wrote:
> I'm actually not using any specific fonts in the current phase.
> Instead of the unicodes starting with '#' the ü is displayed like this: ü
If you don't specify a Font Family then FOP uses "Times" by default.
Indeed the symptoms you describe seem to be more consistent with an
encoding problem than a Font problem. What is the encoding of the source
XML and XSLT files? The XML parser looks at the Byte order Mark as
well as the XML processing instruction.
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Character encoding problem
Posted by Michael Niemann <xm...@yahoo.com>.
I didn't see this before. It solved my problem and the code is a bit nicer, too.
Thanks a lot.
I will also keep the font issue in mind when refining the PDF.
Michael
Manuel Mall <ma...@apache.org> wrote:
Have you seen
http://www.nabble.com/How-to-create-XML-Source-from-Java-String--tf4600917.html?
Jeremias made a point in that post about not using the coding pattern you
use because of encoding issues.
Manuel
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Character encoding problem
Posted by Manuel Mall <ma...@apache.org>.
Have you seen
http://www.nabble.com/How-to-create-XML-Source-from-Java-String--tf4600917.html?
Jeremias made a point in that post about not using the coding pattern you
use because of encoding issues.
Manuel
Michael Niemann wrote:
>
> I'm actually not using any specific fonts in the current phase.
> Instead of the unicodes starting with '#' the ü is displayed like this: ü
>
> Chris Bowditch <bo...@hotmail.com> wrote:
>
> If the PDF isn't showing the correct character it may not be caused by
> encoding problems. If you are seeing a # character where the umlaute
> should be then the problem is caused by the Font you are using not
> having a glyph for the corresponding codepoint. If so, then you will
> need to change the Font Family to one which does a glyph for the German
> Umlaute character.
>
>
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
--
View this message in context: http://www.nabble.com/Character-encoding-problem-tf4790359.html#a13704546
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Character encoding problem
Posted by Michael Niemann <xm...@yahoo.com>.
I'm actually not using any specific fonts in the current phase.
Instead of the unicodes starting with '#' the ü is displayed like this: ü
Chris Bowditch <bo...@hotmail.com> wrote:
If the PDF isn't showing the correct character it may not be caused by
encoding problems. If you are seeing a # character where the umlaute
should be then the problem is caused by the Font you are using not
having a glyph for the corresponding codepoint. If so, then you will
need to change the Font Family to one which does a glyph for the German
Umlaute character.
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Character encoding problem
Posted by Chris Bowditch <bo...@hotmail.com>.
Michael Niemann wrote:
> Hello,
> I've read quite a few older postings about encodig problems and mine
> might not be connected to FOP directly.
> I pass two streams to FOP. The xslt stream includes the output tag with
> its encoding set to UTF-8 but still the resulting pdf doesn't show the
> german Umlaute correctly.
If the PDF isn't showing the correct character it may not be caused by
encoding problems. If you are seeing a # character where the umlaute
should be then the problem is caused by the Font you are using not
having a glyph for the corresponding codepoint. If so, then you will
need to change the Font Family to one which does a glyph for the German
Umlaute character.
<snip/>
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org