You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jos Snellings <jo...@upperware.biz> on 2012/05/08 09:48:41 UTC

userconfig for FOP in Cocoon3

Dear cocooners,

We use FOP to generate a PDF publication of a thesaurus. Needing cyrillic &
greek we have to setup
a user configuration. This is not yet foreseen in the current FOPSerializer.
Yesterday Robby and Ivan were so kind to send me a working Cocoon 2.2
configuration.
This morning, there was room to adapt it to C3.

I suggest that we extend FOPSerializer.java a bit, to include an internal
configuration file & resources.:

 public FlopSerializer(String outputFormat, String userConfigurationPath) {
        if (outputFormat == null) {
            throw new IllegalArgumentException("The parameter
'outputFormat' mustn't be null.");
            }

        URL configurationURL = this.getClass().getResource("/COB-INF/" +
userConfigurationPath);

        try {
            DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
            Configuration cfg =
cfgBuilder.build(configurationURL.openStream());
            FOP_FACTORY.setUserConfig(cfg);

        this.outputFormat = outputFormat;
    }

This way, we can package our custom configuration and the font in the block
jar.

Kind regards,
Jos Snellings



-- 
The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
        -- Gilbert K. Chesterson

Re: userconfig for FOP in Cocoon3

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 08/05/2012 10:43, Jos Snellings wrote:
> I will do that, Francesco!
> However, this patch alters the constructor. This could cause other 
> updates.
> Better override "setup"?
> I think that every pipeline's component setup method is called. I will 
> try that and log it in the ticket.

Good: looking forward for this.

Regards.

> On Tue, May 8, 2012 at 9:51 AM, Francesco Chicchiriccò 
> <ilgrosso@apache.org <ma...@apache.org>> wrote:
>
>     On 08/05/2012 09:48, Jos Snellings wrote:
>
>         Dear cocooners,
>
>         We use FOP to generate a PDF publication of a thesaurus.
>         Needing cyrillic & greek we have to setup
>         a user configuration. This is not yet foreseen in the current
>         FOPSerializer.
>         Yesterday Robby and Ivan were so kind to send me a working
>         Cocoon 2.2 configuration.
>         This morning, there was room to adapt it to C3.
>
>         I suggest that we extend FOPSerializer.java a bit, to include
>         an internal configuration file & resources.:
>
>          public FlopSerializer(String outputFormat, String
>         userConfigurationPath) {
>                if (outputFormat == null) {
>                    throw new IllegalArgumentException("The parameter
>         'outputFormat' mustn't be null.");
>                    }
>
>                URL configurationURL =
>         this.getClass().getResource("/COB-INF/" + userConfigurationPath);
>
>                try {
>                    DefaultConfigurationBuilder cfgBuilder = new
>         DefaultConfigurationBuilder();
>                    Configuration cfg =
>         cfgBuilder.build(configurationURL.openStream());
>                    FOP_FACTORY.setUserConfig(cfg);
>
>                this.outputFormat = outputFormat;
>            }
>
>         This way, we can package our custom configuration and the font
>         in the block jar.
>
>
>     Hi Jos,
>     this looks very nice: could you open an issue on JIRA and provide
>     a proper patch for this? I would be glad to take it, then. Thanks!
>
>     Regards.
>
-- 
Francesco Chicchiriccò

Apache Cocoon PMC and Apache Syncope PPMC Member
http://people.apache.org/~ilgrosso/


Re: userconfig for FOP in Cocoon3

Posted by Jos Snellings <jo...@upperware.biz>.
I will do that, Francesco!
However, this patch alters the constructor. This could cause other updates.
Better override "setup"?
I think that every pipeline's component setup method is called. I will try
that and log it in the ticket.

Ciao,
Jos

On Tue, May 8, 2012 at 9:51 AM, Francesco Chicchiriccò
<il...@apache.org>wrote:

> On 08/05/2012 09:48, Jos Snellings wrote:
>
>> Dear cocooners,
>>
>> We use FOP to generate a PDF publication of a thesaurus. Needing cyrillic
>> & greek we have to setup
>> a user configuration. This is not yet foreseen in the current
>> FOPSerializer.
>> Yesterday Robby and Ivan were so kind to send me a working Cocoon 2.2
>> configuration.
>> This morning, there was room to adapt it to C3.
>>
>> I suggest that we extend FOPSerializer.java a bit, to include an internal
>> configuration file & resources.:
>>
>>  public FlopSerializer(String outputFormat, String userConfigurationPath)
>> {
>>        if (outputFormat == null) {
>>            throw new IllegalArgumentException("The parameter
>> 'outputFormat' mustn't be null.");
>>            }
>>
>>        URL configurationURL = this.getClass().getResource("/**COB-INF/"
>> + userConfigurationPath);
>>
>>        try {
>>            DefaultConfigurationBuilder cfgBuilder = new
>> DefaultConfigurationBuilder();
>>            Configuration cfg = cfgBuilder.build(**
>> configurationURL.openStream())**;
>>            FOP_FACTORY.setUserConfig(cfg)**;
>>
>>        this.outputFormat = outputFormat;
>>    }
>>
>> This way, we can package our custom configuration and the font in the
>> block jar.
>>
>
> Hi Jos,
> this looks very nice: could you open an issue on JIRA and provide a proper
> patch for this? I would be glad to take it, then. Thanks!
>
> Regards.
>
> --
> Francesco Chicchiriccò
>
> Apache Cocoon PMC and Apache Syncope PPMC Member
> http://people.apache.org/~**ilgrosso/<http://people.apache.org/%7Eilgrosso/>
>
>


-- 
The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
        -- Gilbert K. Chesterson

Re: userconfig for FOP in Cocoon3

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 08/05/2012 09:48, Jos Snellings wrote:
> Dear cocooners,
>
> We use FOP to generate a PDF publication of a thesaurus. Needing 
> cyrillic & greek we have to setup
> a user configuration. This is not yet foreseen in the current 
> FOPSerializer.
> Yesterday Robby and Ivan were so kind to send me a working Cocoon 2.2 
> configuration.
> This morning, there was room to adapt it to C3.
>
> I suggest that we extend FOPSerializer.java a bit, to include an 
> internal configuration file & resources.:
>
>  public FlopSerializer(String outputFormat, String 
> userConfigurationPath) {
>         if (outputFormat == null) {
>             throw new IllegalArgumentException("The parameter 
> 'outputFormat' mustn't be null.");
>             }
>
>         URL configurationURL = this.getClass().getResource("/COB-INF/" 
> + userConfigurationPath);
>
>         try {
>             DefaultConfigurationBuilder cfgBuilder = new 
> DefaultConfigurationBuilder();
>             Configuration cfg = 
> cfgBuilder.build(configurationURL.openStream());
>             FOP_FACTORY.setUserConfig(cfg);
>
>         this.outputFormat = outputFormat;
>     }
>
> This way, we can package our custom configuration and the font in the 
> block jar.

Hi Jos,
this looks very nice: could you open an issue on JIRA and provide a 
proper patch for this? I would be glad to take it, then. Thanks!

Regards.

-- 
Francesco Chicchiriccò

Apache Cocoon PMC and Apache Syncope PPMC Member
http://people.apache.org/~ilgrosso/