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 Markus Rietzler <we...@mrietzler.de> on 2015/09/08 18:04:34 UTC

Re: Migration code from 1.1 to 2.0

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:marcel@frightanic.com] 
> Sent: 30 June 2015 20:09
> To: fop-users@xmlgraphics.apache.org
> 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: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 


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