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 "David P. Nesbitt" <da...@yahoo.com> on 2006/06/03 03:33:32 UTC

What happened to base dir in 0.92?

We store our images and font metrics files in a
resource directory in our war file.  Using the
following code in 0.20.5, we could access these images
and font metrics from within the war file.

      org.apache.fop.configuration.Configuration.put(
            "baseDir",
           
AbstractDataRetriever.class.getResource("resource/").getFile());
      org.apache.fop.configuration.Configuration.put(
            "fontBaseDir",
           
AbstractDataRetriever.class.getResource("resource/").getFile());
      File userConfigFile = new
File(AbstractDataRetriever.class.getResource(
            "resource/userconfig.xml").getFile());
      try
      {
         new
org.apache.fop.apps.Options(userConfigFile);
      }
      catch (org.apache.fop.apps.FOPException fope)
      {
         LOG.error("FOP initialization failed!",
fope);
      }

With 0.92, there doesn't seem to be a mechanism for
initializing the baseDir anymore.  Our images are no
longer showing up in the generated PDF files.  Here is
the 0.92 initialization code:

      try
      {
         FOP_FACTORY.setUserConfig(
            AbstractDataRetriever.class.getResource(
               "resource/userconfig.xml").getFile());
         FOP_FACTORY.setFontBaseURL(
            AbstractDataRetriever.class.getResource(
               "resource/").getFile());
      }
      catch (Throwable t)
      {
         LOG.error("FOP initialization failed!", t);
      }

How can we configure FOP version 0.92 to find images
in our war file?

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: What happened to base dir in 0.92?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 05.06.2006 22:23:50 David P. Nesbitt wrote:
> Andreas,
> 
> That did not work.  The FontBaseURL configuration does
> not seem to be working either.  Does FOP 0.92 support
> URL's that are dynamically created from within a
> jar/war file?  Here is the code I added based on your
> suggestion:
> 
>          foUserAgent = fopFactory.newFOUserAgent();
>          foUserAgent.setBaseURL(
>               
> AbstractDataRetriever.class.getResource("resource/").getFile());

Just a suspicion but the line above could be the problem. Instinctively,
I'd say this should be:

AbstractDataRetriever.class.getResource("resource/").toExternalForm());

>          fop =
> fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,
> baos);
> 
> 
> Has anyone got 0.92 working with images and font
> metrics files embedded in jar/war files?  It worked
> fine for me with 0.20.5, but I can't seem to get it to
> work with 0.92.

If you're building WAR files and are using FOP in a servlet, the
ServletContextURIResolver might help you. Search the mailing list
archive for fop-users for "ServletContextURIResolver" to find more info.

<snip/>


Jeremias Maerki


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


Re: What happened to base dir in 0.92?

Posted by "David P. Nesbitt" <da...@yahoo.com>.
Thanks again, Andreas!  I will try that out on Monday
and let you know how it turns out.  As always, I
sincerely appreciate the help!

Regards,
Dave

--- Andreas L Delmelle <a_...@pandora.be>
wrote:

> On Jun 3, 2006, at 19:13, David P. Nesbitt wrote:
> 
> > Andreas,
> >
> > Thanks for the response.  However, I am running in
> > embedded mode, so I don't think the UserAgent
> thing is
> > relevant.  Is it?
> 
> It sure is. Even if you don't instantiate one
> explicitly, FopFactory  
> uses a default FOUserAgent internally.
> 
> > Also, since I want to obtain the
> > resources from the war file, I can't have a static
> > setting in the config file.  It needs to be
> determined
> > at run time.
> 
> That's were the FOUserAgent steps in. Instead of
> relying on the  
> default one provided by FopFactory, you'd
> instantiate one yourself,  
> and feed that back into the newFop() factory method.
> 
> see:
>
http://xmlgraphics.apache.org/fop/0.92/embedding.html#config-
> 
> internal
> mainly the last part about 'Customizing the User
> Agent'
> 
> 
> HTH!
> 
> Andreas
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
> fop-users-help@xmlgraphics.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: What happened to base dir in 0.92?

Posted by "David P. Nesbitt" <da...@yahoo.com>.
Andreas,

Thanks for the help!

Here are the font errors I am getting:

Jun 5, 2006 5:13:56 PM org.apache.fop.fonts.FontInfo
notifyFontReplacement
WARNING: Font 'Arial,normal,700' not found.
Substituting with default font.
Jun 5, 2006 5:13:56 PM org.apache.fop.fonts.FontInfo
notifyFontReplacement
WARNING: Font 'Arial,normal,400' not found.
Substituting with default font.

And here are the configuration file entries that I am
using:

<fonts>
 <font metrics-file="arial.xml" kerning="yes"
embed-file="C:\WINDOWS\Fonts\arial.ttf">
    <font-triplet name="Arial" style="normal"
weight="normal"/>
    <font-triplet name="ArialMT" style="normal"
weight="normal"/>
 </font>
 <font metrics-file="arialbd.xml" kerning="yes"
embed-file="C:\WINDOWS\Fonts\arialbd.ttf">
    <font-triplet name="Arial" style="normal"
weight="bold"/>
    <font-triplet name="ArialMT" style="normal"
weight="bold"/>
 </font>
</fonts>

Any ideas?

Regards,
Dave

--- Andreas L Delmelle <a_...@pandora.be>
wrote:

> On Jun 5, 2006, at 22:23, David P. Nesbitt wrote:
> 
> Hi David,
> 
> > That did not work.  The FontBaseURL configuration
> does
> > not seem to be working either.  Does FOP 0.92
> support
> > URL's that are dynamically created from within a
> > jar/war file?
> 
> Well... ultimately it is nothing more than a String
> from which a URL  
> is constructed
> --whether that String is hardcoded or created at
> runtime should not  
> be an issue :/
> 
> Frankly, without more info, I'm clueless ATM as to
> why it doesn't  
> work... Do you receive any error messages
> whatsoever? (About missing  
> images or font metrics, maybe? Does it say which
> location is being  
> searched?)
> 
> Anyone?
> 
> Cheers,
> 
> Andreas
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
> fop-users-help@xmlgraphics.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: What happened to base dir in 0.92?

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jun 5, 2006, at 22:23, David P. Nesbitt wrote:

Hi David,

> That did not work.  The FontBaseURL configuration does
> not seem to be working either.  Does FOP 0.92 support
> URL's that are dynamically created from within a
> jar/war file?

Well... ultimately it is nothing more than a String from which a URL  
is constructed
--whether that String is hardcoded or created at runtime should not  
be an issue :/

Frankly, without more info, I'm clueless ATM as to why it doesn't  
work... Do you receive any error messages whatsoever? (About missing  
images or font metrics, maybe? Does it say which location is being  
searched?)

Anyone?

Cheers,

Andreas

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


Re: What happened to base dir in 0.92?

Posted by "David P. Nesbitt" <da...@yahoo.com>.
Andreas,

That did not work.  The FontBaseURL configuration does
not seem to be working either.  Does FOP 0.92 support
URL's that are dynamically created from within a
jar/war file?  Here is the code I added based on your
suggestion:

         foUserAgent = fopFactory.newFOUserAgent();
         foUserAgent.setBaseURL(
              
AbstractDataRetriever.class.getResource("resource/").getFile());
         fop =
fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,
baos);


Has anyone got 0.92 working with images and font
metrics files embedded in jar/war files?  It worked
fine for me with 0.20.5, but I can't seem to get it to
work with 0.92.

Regards,
Dave


--- Andreas L Delmelle <a_...@pandora.be>
wrote:

> On Jun 3, 2006, at 19:13, David P. Nesbitt wrote:
> 
> > Andreas,
> >
> > Thanks for the response.  However, I am running in
> > embedded mode, so I don't think the UserAgent
> thing is
> > relevant.  Is it?
> 
> It sure is. Even if you don't instantiate one
> explicitly, FopFactory  
> uses a default FOUserAgent internally.
> 
> > Also, since I want to obtain the
> > resources from the war file, I can't have a static
> > setting in the config file.  It needs to be
> determined
> > at run time.
> 
> That's were the FOUserAgent steps in. Instead of
> relying on the  
> default one provided by FopFactory, you'd
> instantiate one yourself,  
> and feed that back into the newFop() factory method.
> 
> see:
>
http://xmlgraphics.apache.org/fop/0.92/embedding.html#config-
> 
> internal
> mainly the last part about 'Customizing the User
> Agent'
> 
> 
> HTH!
> 
> Andreas
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
> fop-users-help@xmlgraphics.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: What happened to base dir in 0.92?

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jun 3, 2006, at 19:13, David P. Nesbitt wrote:

> Andreas,
>
> Thanks for the response.  However, I am running in
> embedded mode, so I don't think the UserAgent thing is
> relevant.  Is it?

It sure is. Even if you don't instantiate one explicitly, FopFactory  
uses a default FOUserAgent internally.

> Also, since I want to obtain the
> resources from the war file, I can't have a static
> setting in the config file.  It needs to be determined
> at run time.

That's were the FOUserAgent steps in. Instead of relying on the  
default one provided by FopFactory, you'd instantiate one yourself,  
and feed that back into the newFop() factory method.

see: http://xmlgraphics.apache.org/fop/0.92/embedding.html#config- 
internal
mainly the last part about 'Customizing the User Agent'


HTH!

Andreas

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


Re: What happened to base dir in 0.92?

Posted by "David P. Nesbitt" <da...@yahoo.com>.
Andreas,

Thanks for the response.  However, I am running in
embedded mode, so I don't think the UserAgent thing is
relevant.  Is it?  Also, since I want to obtain the
resources from the war file, I can't have a static
setting in the config file.  It needs to be determined
at run time.

Anyone know how to do this for embedded mode?

Regards,
Dave

--- Andreas L Delmelle <a_...@pandora.be>
wrote:

> On Jun 3, 2006, at 03:33, David P. Nesbitt wrote:
> 
> Hi David,
> 
> > <snip />
> > With 0.92, there doesn't seem to be a mechanism
> for
> > initializing the baseDir anymore.
> 
> Yes there is, only not directly through a factory
> method.
> IIC, then what you're after is either:
> - the baseURL entry in the config file
> - the setBaseURL() method of FOUserAgent
> 
> 
> HTH!
> 
> Cheers,
> 
> Andreas
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
> fop-users-help@xmlgraphics.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: What happened to base dir in 0.92?

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jun 3, 2006, at 03:33, David P. Nesbitt wrote:

Hi David,

> <snip />
> With 0.92, there doesn't seem to be a mechanism for
> initializing the baseDir anymore.

Yes there is, only not directly through a factory method.
IIC, then what you're after is either:
- the baseURL entry in the config file
- the setBaseURL() method of FOUserAgent


HTH!

Cheers,

Andreas


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