You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Myriam Delperier <my...@ajlsm.com> on 2005/11/16 08:30:00 UTC

pdf serializer encoding

Hi,

I'm creating pdf files with something like :
<map:generate type="xsp" src="myfile.xsp"/>
<map:transform src="myfile.xsl"/>
<map:serialize type="fo2pdf" />

the result is a pdf page with ISO-8859-1 encoding, and I need an UTF-8 
encoding.
I've tried
<xsl:output encoding="UTF-8"/> in the xsl file,
<map:serializer name="fo2pdf" logger="sitemap.serializer.fo2pdf" 
mime-type="application/pdf" 
src="org.apache.cocoon.serialization.FOPSerializer"/>
    <encoding>UTF-8</encoding>
 </map:serializer> in the sitemap
but none of those solutions work.

Does somebody knows how to fix this?

thanks 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| | you might want to use Java's urlencode function in your fo
| | producing xslt

you're right that's work great.

As I'm using saxon as xsl transformer iIve something like :
urle:encode(string($val), 'UTF-8') and 
xmlns:urle="java:java.net.URLEncoder"
instead.

But I don't know if this works with xalan...

Thanks a lot. 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Marc Portier <mp...@outerthought.org>.
you might want to use Java's urlencode function in your fo producing xslt

add
	xmlns:urlencoder="xalan://java.net.URLEncoder
then use
	urlencoder:encode(@url,'UTF-8');

warnings:
- this makes your xslt less portable of course, but it 'll nicely run in
the cocoon env
- watch out with the sequence of encoding and concatenating since I'm
doubthing if this will encode the '?', '/', '&' and '=' as well


Myriam Delperier wrote:
> | | I'm not sure if it's a good idea to set the container-encoding to
> | | utf-8. Cocoon's web.xml says about the container-encoding:
> | | "Since the servlet specification requires that the ISO-8859-1
> | | encoding
> | | is used (by default), you should never change this value unless you
> | | have a buggy servlet container."
> | |

indeed this variable tells to cocoon (only) which encoding was used by
your servlet-container on the http-request... so it's not really driving
anything, just telling cocoon what happened to the data it's getting

and the term 'buggy container' isn't really correct, the far from buggy
container jetty allows through a system property to actually set the
container-encoding to utf-8
(I'm even under the impression that version 5 does this by default)

so *ONLY* in those cases you need to change this setting in the web.xml


> | | Maybe if you set this back to iso, it will work with the iso-encoded
> | | urls. Just a guess...
> 
> I've made this chande but
> unfortunately the pb is still the same
> 

so no surprise here

HTH,

-marc=
-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| | I'm not sure if it's a good idea to set the container-encoding to
| | utf-8. Cocoon's web.xml says about the container-encoding:
| | "Since the servlet specification requires that the ISO-8859-1
| | encoding
| | is used (by default), you should never change this value unless you
| | have a buggy servlet container."
| |
| | Maybe if you set this back to iso, it will work with the iso-encoded
| | urls. Just a guess...

I've made this chande but
unfortunately the pb is still the same 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Josias Thoeny <jo...@wyona.com>.
On Wed, 2005-11-16 at 10:15 +0100, Myriam Delperier wrote:
> | | Does it make a difference to set default encoding of Cocoon to
> | | utf-8? I believe it is a property in the cocoon.xconf or perhaps
> | | the web.xml.
> 
> it's already the case, in my web.xml file  I've :
> <init-param>
>  <param-name>form-encoding</param-name>
>  <param-value>UTF-8</param-value>
> </init-param>
> <init-param>
>  <param-name>container-encoding</param-name>
>  <param-value>UTF-8</param-value>
> </init-param>

I'm not sure if it's a good idea to set the container-encoding to utf-8.
Cocoon's web.xml says about the container-encoding:
"Since the servlet specification requires that the ISO-8859-1 encoding
is used (by default), you should never change this value unless you have
a buggy servlet container."

Maybe if you set this back to iso, it will work with the iso-encoded
urls. Just a guess...

- Josias

> <init-param>
>  <param-name>encoding</param-name>
>  <param-value>UTF-8</param-value>
> </init-param>
> 
> so all the pages, and everything in my application is in UTF-8,
> except my pdf pages.
> As the links in those pages link to other pages of my application which 
> are in UTF-8 and wait for UTF-8, it doesn't fit. 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| | Does it make a difference to set default encoding of Cocoon to
| | utf-8? I believe it is a property in the cocoon.xconf or perhaps
| | the web.xml.

it's already the case, in my web.xml file  I've :
<init-param>
 <param-name>form-encoding</param-name>
 <param-value>UTF-8</param-value>
</init-param>
<init-param>
 <param-name>container-encoding</param-name>
 <param-value>UTF-8</param-value>
</init-param>
<init-param>
 <param-name>encoding</param-name>
 <param-value>UTF-8</param-value>
</init-param>

so all the pages, and everything in my application is in UTF-8,
except my pdf pages.
As the links in those pages link to other pages of my application which 
are in UTF-8 and wait for UTF-8, it doesn't fit. 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Geert Josten <Ge...@daidalos.nl>.
> in fact the characters are well displayed, but I've in my file some 
> external links like :
> <fo:basic-link 
> external-destination="resultats-in.html?q=finstitutiontype:|Service 
> général|">Service général</fo:basic-link> and the result of the link is :
> resultats-in.html?q=finstitutiontype:|Service%20g%e9n%e9ral| whereas I'm 
> waiting for :
> resultats-in.html?q=finstitutiontype:|Service%20g%C3%A9n%C3%A9ral|

Isn't url-encoding standardized? (to some iso codepage)

Does it make a difference to set default encoding of Cocoon to utf-8? I believe it is a property in 
the cocoon.xconf or perhaps the web.xml.

Regards,
Geert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| I guess we'll have to change the name of
| the transformer at some point...

and keep this name for a transformer which really encodes (with a given 
encoding) given patterns :-)
that would be great! 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 nov. 05, à 11:18, Bertrand Delacretaz a écrit :

> Looks like the encoreURL transformer is not encoding...

hmmm...cough...well...turns out that the EncodeURL transformer does  
*not* encode URLs as its name seems to indicate, it adds sessionIDs to  
them. I just checked the encodeurl-* test cases that I updated in  
http://svn.apache.org/repos/asf/cocoon/trunk/src/test/org/apache/ 
cocoon/transformation/  - looks like short memory on my side ;-)

So this wouldn't help in your case, Marc's solution with an XSLT  
extension does.

Sorry for misleading you, and I guess we'll have to change the name of  
the transformer at some point...

-Bertrand

Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| Looks like the encoreURL transformer is not encoding - I'm not too
| familiar with its details but you might want to try
|
| <include-name>.*external-destination</include-name>
|
| in case the namespace confuses it, or even
|
| <include-name>.*</include-name>

i've this : 
<include-name>.*/@external-destination|.*external-destination|.*|.*/@*</include-name>

none of those work, nothing is encoded.

I wonder if this transformer works on fo files ...

anywai it could have been a good idea, thanks for your help 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 nov. 05, à 11:11, Myriam Delperier a écrit :

> ...I don't see any changes:
> <fo:basic-link  
> external-destination="resultats-in.htmlq=finstitutiontype: 
> |Servicegénéral|&base=institution&from1=rechterm&sf=ftitle">Service  
> général</fo:basic-link>
>
> im my sitemap I've :
> <map:transformer name="encodeURL"  
> src="org.apache.cocoon.transformation.EncodeURLTransformer">
>    <include-name>.*/@external-destination</include-name>
> </map:transformer>..

Looks like the encoreURL transformer is not encoding - I'm not too  
familiar with its details but you might want to try

<include-name>.*external-destination</include-name>

in case the namespace confuses it, or even

<include-name>.*</include-name>

As a test, this should encode all attributes.

-Bertrand

Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| What do you see at the output of the encodeURL transformer?
| You can see this by replacing the fo2pdf serializer with an xml one,
| or using a view.

I don't see any changes:
<fo:basic-link 
external-destination="resultats-in.htmlq=finstitutiontype:|Servicegénéral|&base=institution&from1=rechterm&sf=ftitle">Service 
général</fo:basic-link>

im my sitemap I've :
<map:transformer name="encodeURL" 
src="org.apache.cocoon.transformation.EncodeURLTransformer">
    <include-name>.*/@external-destination</include-name>
</map:transformer>

and

<map:generate type="xsp" src="myfile.xsp"/>
<map:transform src="myfile.xsl"/>
<map:transform type="encodeURL"/>
<map:serialize type="xml" /> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 nov. 05, à 11:00, Myriam Delperier a écrit :

> | See
> | http://cocoon.apache.org/2.1/userdocs/transformers/encodeurl-
> | transformer.html and try adding
> | |    <map:transform type="encodeURL"/>
> | | before the fo2pdf serializer, assuming the encodeURL transformer is
> | already configured in your sitemap.
>
>
> i've tried it and my urls still aren't correct

What do you see at the output of the encodeURL transformer?
You can see this by replacing the fo2pdf serializer with an xml one, or 
using a view.

-Bertrand

Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
 
| See
| http://cocoon.apache.org/2.1/userdocs/transformers/encodeurl-
| transformer.html and try adding
| 
|    <map:transform type="encodeURL"/>
| 
| before the fo2pdf serializer, assuming the encodeURL transformer is
| already configured in your sitemap.


i've tried it and my urls still aren't correct

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
| I'm not 100% sure how this is handled in PDF, but my guess is that you
| should encode your URLs before they get to the serializer.
| 
| See
| http://cocoon.apache.org/2.1/userdocs/transformers/encodeurl-
| transformer.html and try adding
| 
|    <map:transform type="encodeURL"/>
| 
| before the fo2pdf serializer, assuming the encodeURL transformer is
| already configured in your sitemap.
| 

ok, i'll try this and tell you

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 nov. 05, à 08:45, Myriam Delperier a écrit :

> ....in fact the characters are well displayed, but I've in my file  
> some external links like :
> <fo:basic-link  
> external-destination="resultats-in.html?q=finstitutiontype:|Service  
> général|">Service général</fo:basic-link> and the result of the link  
> is :
> resultats-in.html?q=finstitutiontype:|Service%20g%e9n%e9ral| whereas  
> I'm waiting for :
> resultats-in.html?q=finstitutiontype:|Service%20g%C3%A9n%C3%A9ral|

I'm not 100% sure how this is handled in PDF, but my guess is that you  
should encode your URLs before they get to the serializer.

See  
http://cocoon.apache.org/2.1/userdocs/transformers/encodeurl- 
transformer.html and try adding

   <map:transform type="encodeURL"/>

before the fo2pdf serializer, assuming the encodeURL transformer is  
already configured in your sitemap.

-Bertrand

Re: pdf serializer encoding

Posted by Myriam Delperier <my...@ajlsm.com>.
Geert Josten wrote:
| | Isn't the PDF format written in low-ascii? So it shouldn't matter.
| | If you want unicode characters to be shown, use character
| | references or utf-8 in the FO document and reference to a Unicode
| | capable font supported by FOP.

in fact the characters are well displayed, but I've in my file some 
external links like :
<fo:basic-link 
external-destination="resultats-in.html?q=finstitutiontype:|Service 
général|">Service général</fo:basic-link> and the result of the link is 
:
resultats-in.html?q=finstitutiontype:|Service%20g%e9n%e9ral| whereas I'm 
waiting for :
resultats-in.html?q=finstitutiontype:|Service%20g%C3%A9n%C3%A9ral| 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Geert Josten <Ge...@daidalos.nl>.
Isn't the PDF format written in low-ascii? So it shouldn't matter. If you want unicode characters to 
be shown, use character references or utf-8 in the FO document and reference to a Unicode capable 
font supported by FOP.

Regards,
Geert

Myriam Delperier wrote:

> Hi,
> 
> I'm creating pdf files with something like :
> <map:generate type="xsp" src="myfile.xsp"/>
> <map:transform src="myfile.xsl"/>
> <map:serialize type="fo2pdf" />
> 
> the result is a pdf page with ISO-8859-1 encoding, and I need an UTF-8 
> encoding.
> I've tried
> <xsl:output encoding="UTF-8"/> in the xsl file,
> <map:serializer name="fo2pdf" logger="sitemap.serializer.fo2pdf" 
> mime-type="application/pdf" 
> src="org.apache.cocoon.serialization.FOPSerializer"/>
>    <encoding>UTF-8</encoding>
> </map:serializer> in the sitemap
> but none of those solutions work.
> 
> Does somebody knows how to fix this?
> 
> thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pdf serializer encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 nov. 05, à 08:30, Myriam Delperier a écrit :

> ...I'm creating pdf files with something like :
> <map:generate type="xsp" src="myfile.xsp"/>
> <map:transform src="myfile.xsl"/>
> <map:serialize type="fo2pdf" />
>
> the result is a pdf page with ISO-8859-1 encoding, and I need an UTF-8 
> encoding....

What do you mean by that, what symptoms do you see?

If it's the accented characters which are wrong in your PDF output, it 
usually means that your *data* is garbled, not the PDF.

Trying <map:serialize type="xml"/> instead of fo2pdf should show you 
the problem, if the characters are still wrong you have an encoding 
problem upstream, either in myfile.xsp, in myfile.xsl or in your data.

-Bertrand