OK - figured it out.  Thanks, Chris, for the tip.  Here is the example (using 
itext for pdf): 
 
            if (StringUtils.isNotBlank(logoFile))
            {
             try
             {
              Asset logoAss = 
assetSource.getClasspathAsset("context:layout/images/" + 
StringUtils.trimToEmpty(logoFile));
                     java.awt.Image logoImage = 
Toolkit.getDefaultToolkit().createImage(logoAss.getResource().toURL());
                     if (logoImage != null)
                     {
                      com.itextpdf.text.Image logo2 = 
com.itextpdf.text.Image.getInstance(logoImage, null); 
                      if (logo2 != null) 
                      {
                     table.addCell(new PdfPCell(new Phrase("Logo")));
                     table.addCell(logo2);
                      }
                     }
             }
             catch (Exception e)
             {
              logger.info("Unable to process logo file " + logoFile + " while 
rendering PDF of Orgs List");
              logger.info(e);;
             }
            }
 


On Tuesday, July 1, 2014 10:21 AM, Net Dawg <net.d...@yahoo.com.INVALID> wrote:
  


Is there an example of this?  Meanwhile I found this nugget in SO: 
 
http://stackoverflow.com/questions/19301034/how-to-get-the-asset-path-in-tapestry-5



On Tuesday, July 1, 2014 9:25 AM, Chris Poulsen <mailingl...@nesluop.dk> wrote:
  


Inject AssetSource and set up things programmatically ?

-- 
Chris



On Tue, Jul 1, 2014 at 8:58 PM, Net Dawg <net.d...@yahoo.com.invalid> wrote:

> How can I import an image into page class (without advance knowledge of
> its name)?  I would like to use it to stream PDF dynamically.
>
> According to Assets in Component Classes(
> http://tapestry.apache.org/assets.html), components learn about assets
> via injection. The @Inject annotation allows Assets to be injected into
> components as read-only
> properties. The path to the resource is specified using the Path
> annotation:
>
> @Inject
> @Path("context:images/tapestry_banner.gif")
> private Asset banner;
>
> Assets are located within domains; these domains are identified by the
> prefix on the @Path annotation's value.
>
> QUESTION:  What if I do not know filename (tapestry_banner.gif) in advance
> and it is fed to me from database?  In my case, I have several hundred such
> assets...from which I have to select the one I need based on what is tagged
> in the database...it would not be realistic to inject every one of them
> into page (or is it?).  Say all my images are in exactly the same directory
> called images under webapp\layout\images and I get the filename say
> image001.gif, how could I do something like this:
>
> Asset image = createImage([what?]image001.gif);

Reply via email to