Hi Al,
I'm sorry, that's my mistake. The setUserConfig line needs to be inside of
a function. It should probably be moved from where it is to inside the
convertFO2PDF function like this:
...
public void convertFO2PDF(File fo, File pdf) throws IOException,
FOPException {
* fopFactory.setUserConfig(new File("/opt/coolstack/fop/conf/fop.xconf""));*
OutputStream out = null;
try {
...
Hope that Helps!
On Tue, Apr 21, 2009 at 8:47 AM, Al Dancer <[email protected]> wrote:
> Hello,
>
> I added the lines to ExampleFO2PDF.java and tried to compile it.
> The java compilation failed :
>
> www-slave:root>javac ExampleFO2PDF.java
> ExampleFO2PDF.java:60: <identifier> expected
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: illegal start of type
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: ')' expected
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: ';' expected
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: illegal start of type
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: <identifier> expected
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> ExampleFO2PDF.java:60: ';' expected
> fopFactory.setUserConfig(new
> File("/opt/coolstack/fop/conf/fop.xconf"));
> ^
> 7 errors
>
> Any idea ?
>
> thanks,
>
> Al
> --- On *Tue, 4/21/09, Al Dancer <[email protected]>* wrote:
>
>
> From: Al Dancer <[email protected]>
> Subject: Re: FOP in servlet and configuration
> To: [email protected]
> Date: Tuesday, April 21, 2009, 5:08 AM
>
>
> Hello Sam,
>
> thank you, I will recompile the Java script, and create a new class,
> then will try it.
>
> Al.
>
> --- On *Tue, 4/21/09, Sam Fuqua <[email protected]>* wrote:
>
>
> From: Sam Fuqua <[email protected]>
> Subject: Re: FOP in servlet and configuration
> To: [email protected]
> Date: Tuesday, April 21, 2009, 4:36 AM
>
> Hi Al,
>
> You need to put those lines in the Java file that contains your
> FopFactory. The imports go at the top with the rest of your imports, and
> the setUserConfig line needs to be inserted just after the FopFactory is
> initialized, but before you use it to create another object.
>
> Assuming you are still using some altered version of the ExampleFO2PDF
> class, you'd need something like the following:
> ...
> *import org.apache.avalon.framework.configuration.Configuration;
> import
> org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;*
>
> public class ExampleFO2PDF {
>
>
> // configure fopFactory as desired
> private FopFactory fopFactory = FopFactory.newInstance();
> *fopFactory.setUserConfig(new File("/opt/fop/conf/fop.xconf"));*
> /**
>
> * Converts an FO file to a PDF file using FOP
> * @param fo the FO file
> * @param pdf the target PDF file
> * @throws IOException In case of an I/O problem
> * @throws FOPException In case of a FOP problem
>
> */
> public void convertFO2PDF(File fo, File pdf) throws IOException,
> FOPException {
> ...
>
> This of course assumes that your FopFactory is called fopFactory. Hope
> that helped!
>
>
> On Tue, Apr 21, 2009 at 5:29 AM, Al Dancer <[email protected]> wrote:
>
>> Hello,
>>
>> I'm running FOP 0.95 and Tomcat 6, OS : Solaris 10, java version
>> "1.6.0_10"
>>
>> How can I tell the FOP in Servlet to use my FOP configuration from file
>> /opt/fop/conf/fop.xconf ?
>>
>> When I run from web:
>> http://localhost:8080/fop/fop?fo=/home/path/to/fofile.fo
>>
>> I see the PDF document, but without my fonts (which are from my
>> fop.xconf).
>> It seems, the FOP in servlet, didn't read the FOP config file at all.
>> When I run the fop from command line:
>> fop -c /opt/fop/conf/fop.xconf -fo /home/path/to/fofile.fo -pdf
>> /tmp/fofile.pdf
>> the created PDF file is with the correct fonts.
>>
>> I read the FOP document about configuration file at:
>> http://xmlgraphics.apache.org/fop/0.94/embedding.html#config-external
>>
>> But, in which script (java) should I add the following lines, so I can use
>> FOP in servlet with
>> configuration ?
>>
>> import org.apache.avalon.framework.configuration.Configuration;
>> import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
>>
>>
>> fopFactory.setUserConfig(new File("/opt/fop/conf/fop.xconf"));
>>
>> Any help would be appreciated.
>>
>> Al
>>
>>
>>
>>
>
>
> --
> Sam Fuqua
> ΣΝ ΘΗ 454
>
>
>
>
--
Sam Fuqua
ΣΝ ΘΗ 454