Migration code from 1.1 to 2.0

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Migration code from 1.1 to 2.0

Marcel Stör
I've got a similar issue as asked in
http://markmail.org/message/cme6pd2wo54o4lci.

In 1.1 there was:

fopFactory = FopFactory.newInstance();
if (baseUrl != null) {
   fopFactory.setBaseURL(baseUrl.getURL().toExternalForm());
}
if (configLocation != null) {
   fopFactory.setUserConfig(configLocation.getURI().toString());
}

The closest I could replicate this for 2.0 is:

FopFactoryBuilder  fopFactoryBuilder = new
FopFactoryBuilder(baseUrl.getURI());
if (configLocation != null) {
   DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
   try {
     Configuration cfg = cfgBuilder.buildFromFile(configLocation.getFile());
     fopFactoryBuilder.setConfiguration(cfg);
   } catch (ConfigurationException e) {
     throw new IOException("Failed to use FOP configuration at " +
configLocation.getURL(), e);
   }
}
fopFactory = fopFactoryBuilder.build();

Is that ok? For the 2.0 version I had to ensure that my 'baseUrl' is
never null because there doesn't seem to be a
FopFactory/FopFactoryBuilder constructor which doesn't expect a base URL.

--
Marcel Stör, http://frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - http://bit.ly/1sNwXAM

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Migration code from 1.1 to 2.0

Simon Steiner
Hi,

I use:

        FopFactoryBuilder confBuilder = new FopConfParser(fopxconf, new File(".").toURI()).getFopFactoryBuilder();
        FopFactory fopFactory = confBuilder.build();

Thanks

-----Original Message-----
From: Marcel Stör [mailto:[hidden email]]
Sent: 30 June 2015 20:09
To: [hidden email]
Subject: Migration code from 1.1 to 2.0

I've got a similar issue as asked in
http://markmail.org/message/cme6pd2wo54o4lci.

In 1.1 there was:

fopFactory = FopFactory.newInstance();
if (baseUrl != null) {
   fopFactory.setBaseURL(baseUrl.getURL().toExternalForm());
}
if (configLocation != null) {
   fopFactory.setUserConfig(configLocation.getURI().toString());
}

The closest I could replicate this for 2.0 is:

FopFactoryBuilder  fopFactoryBuilder = new FopFactoryBuilder(baseUrl.getURI());
if (configLocation != null) {
   DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
   try {
     Configuration cfg = cfgBuilder.buildFromFile(configLocation.getFile());
     fopFactoryBuilder.setConfiguration(cfg);
   } catch (ConfigurationException e) {
     throw new IOException("Failed to use FOP configuration at " + configLocation.getURL(), e);
   }
}
fopFactory = fopFactoryBuilder.build();

Is that ok? For the 2.0 version I had to ensure that my 'baseUrl' is never null because there doesn't seem to be a FopFactory/FopFactoryBuilder constructor which doesn't expect a base URL.

--
Marcel Stör, http://frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - http://bit.ly/1sNwXAM

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Migration code from 1.1 to 2.0

Markus Rietzler
is there any working example with custom config and pdfencryption

at the moment i am using fop 1.1. with the following additions and changes. the documentation on the fop homepage is not
very clear - i am not a java expert, and the examples did not work.

import org.xml.sax.SAXException;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.fop.pdf.PDFEncryptionParams;



    protected void configureFopFactory() {
        //Subclass and override this method to perform additional configuration
        try {
                fopFactory.setUserConfig(new File("/path/to/fop/conf2.xml"));
        } catch (SAXException e) {
                System.out.println(e);
        } catch (IOException e) {
                System.out.println(e);
        }
    }


    protected FOUserAgent getFOUserAgent() {
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
        //Configure foUserAgent as desired
                userAgent.getRendererOptions().put("encryption-params", new PDFEncryptionParams(
                         null, "pass", true, false, false, false));
        return userAgent;
    }


Am 30.06.15 um 21:43 schrieb Simon Steiner:

> Hi,
>
> I use:
>
>         FopFactoryBuilder confBuilder = new FopConfParser(fopxconf, new File(".").toURI()).getFopFactoryBuilder();
>         FopFactory fopFactory = confBuilder.build();
>
> Thanks
>
> -----Original Message-----
> From: Marcel Stör [mailto:[hidden email]]
> Sent: 30 June 2015 20:09
> To: [hidden email]
> Subject: Migration code from 1.1 to 2.0
>
> I've got a similar issue as asked in
> http://markmail.org/message/cme6pd2wo54o4lci.
>
> In 1.1 there was:
>
> fopFactory = FopFactory.newInstance();
> if (baseUrl != null) {
>    fopFactory.setBaseURL(baseUrl.getURL().toExternalForm());
> }
> if (configLocation != null) {
>    fopFactory.setUserConfig(configLocation.getURI().toString());
> }
>
> The closest I could replicate this for 2.0 is:
>
> FopFactoryBuilder  fopFactoryBuilder = new FopFactoryBuilder(baseUrl.getURI());
> if (configLocation != null) {
>    DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
>    try {
>      Configuration cfg = cfgBuilder.buildFromFile(configLocation.getFile());
>      fopFactoryBuilder.setConfiguration(cfg);
>    } catch (ConfigurationException e) {
>      throw new IOException("Failed to use FOP configuration at " + configLocation.getURL(), e);
>    }
> }
> fopFactory = fopFactoryBuilder.build();
>
> Is that ok? For the 2.0 version I had to ensure that my 'baseUrl' is never null because there doesn't seem to be a FopFactory/FopFactoryBuilder constructor which doesn't expect a base URL.
>
> --
> Marcel Stör, http://frightanic.com
> Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
> O< ascii ribbon campaign - stop html mail - http://bit.ly/1sNwXAM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]