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 ir...@dotech.com on 2005/01/18 17:18:54 UTC
Image callback for each page?
We have an api that generates a sort of "barcode" image that needs to be put on
the bottom of each page. However, each image is unique and needs to be
generated with some information from the xml document. I know I can do this by
using a REST api call and putting a URL in the fo:graphic that dynamically
generates the image. However, I'd rather do it right in the Java code that
sets up the Driver. So, is this possible? Some thoughts I have, but don't
know if they exist:
1. Can I get a callback that calls my Java code when a certain fo:graphic
element is hit and let me dynamically put the XSL:FO content in there? This
would allow me to dynamically generate the images on the fly and put the
appropriate image content in .
2. Can I put custom xsl:fo elements in the document and then register my own
"renderers" for dealing with those types?
Any reccomendations and/or help would be greatly appreciated.
Irv
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Image callback for each page?
Posted by ir...@dotech.com.
Quoting The Web Maestro <th...@gmail.com>:
>
> On Jan 18, 2005, at 8:18 AM, irv@dotech.com wrote:
> > We have an api that generates a sort of "barcode" image that needs to
> > be put on
> > the bottom of each page. However, each image is unique and needs to be
> > generated with some information from the xml document. I know I can
> > do this by
> > using a REST api call and putting a URL in the fo:graphic that
> > dynamically
> > generates the image. However, I'd rather do it right in the Java code
> > that
> > sets up the Driver. So, is this possible? Some thoughts I have, but
> > don't
> > know if they exist:
> >
> > 1. Can I get a callback that calls my Java code when a certain
> > fo:graphic
> > element is hit and let me dynamically put the XSL:FO content in there?
> > This
> > would allow me to dynamically generate the images on the fly and put
> > the
> > appropriate image content in .
> > 2. Can I put custom xsl:fo elements in the document and then register
> > my own
> > "renderers" for dealing with those types?
> >
> > Any reccomendations and/or help would be greatly appreciated.
>
> You can do this either by embedding a barcode font[1] or by using the
> excellent and open source Barcode4J[1], which is listed in the FOP
> Resources page "FOP Add-ons' section. As for a callback, I suspect it's
> possible, but don't know how.
>
> Good luck!
>
Unfortunately, we have to use our own api, not just a regular barcode. It is
actually a dataglyph that we generate. So, I still do need the callback or
custom element renderer.
Thanks,
Irv
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Image callback for each page?
Posted by The Web Maestro <th...@gmail.com>.
On Jan 18, 2005, at 8:18 AM, irv@dotech.com wrote:
> We have an api that generates a sort of "barcode" image that needs to
> be put on
> the bottom of each page. However, each image is unique and needs to be
> generated with some information from the xml document. I know I can
> do this by
> using a REST api call and putting a URL in the fo:graphic that
> dynamically
> generates the image. However, I'd rather do it right in the Java code
> that
> sets up the Driver. So, is this possible? Some thoughts I have, but
> don't
> know if they exist:
>
> 1. Can I get a callback that calls my Java code when a certain
> fo:graphic
> element is hit and let me dynamically put the XSL:FO content in there?
> This
> would allow me to dynamically generate the images on the fly and put
> the
> appropriate image content in .
> 2. Can I put custom xsl:fo elements in the document and then register
> my own
> "renderers" for dealing with those types?
>
> Any reccomendations and/or help would be greatly appreciated.
You can do this either by embedding a barcode font[1] or by using the
excellent and open source Barcode4J[1], which is listed in the FOP
Resources page "FOP Add-ons' section. As for a callback, I suspect it's
possible, but don't know how.
Good luck!
[1]
http://user.it.uu.se/~jan/barfonts/
[2]
http://xml.apache.org/fop/resources.html#products-fop-add-ons
Web Maestro Clay
--
<th...@gmail.com> - <http://homepage.mac.com/webmaestro/>
My religion is simple. My religion is kindness.
- HH The 14th Dalai Lama of Tibet
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: Image callback for each page?
Posted by Victor Mote <vi...@outfitr.com>.
irv@dotech.com wrote:
> We have an api that generates a sort of "barcode" image that
> needs to be put on the bottom of each page. However, each
> image is unique and needs to be generated with some
> information from the xml document. I know I can do this by
> using a REST api call and putting a URL in the fo:graphic
> that dynamically generates the image. However, I'd rather do
> it right in the Java code that sets up the Driver. So, is
> this possible? Some thoughts I have, but don't know if they exist:
My guess is that markers with a URL would be the easiest and most standard
way to do this. But I'll take your word for it that you want the callback.
> 1. Can I get a callback that calls my Java code when a
> certain fo:graphic element is hit and let me dynamically put
> the XSL:FO content in there? This would allow me to
> dynamically generate the images on the fly and put the
> appropriate image content in .
I think you can do this, but again, it seems like a pain. IIRC correctly,
the FONode class has a getParent() method which can be used to recursively
go up the tree until you get to the Root (keep in mind that this is XML/FO
inheritance, not Java inheritance). I would cache the object that will
generate the image in Root, and, if it does not exist already, write an
FONode method called getRoot() which will recursively go up the tree to Root
and return Root. Then, you'll need to modify the code that creates the image
in the AreaTree, and then use your (presumably) ExternalGraphic node to do
something like the following:
YourGraphicMaker ygm =
externalGraphic.getRoot().getYourGraphicMaker();
Image image = ygm.makeGraphic(externalGraphic);
// pass the image instance where it needs to go.
I have used the above technique successfully to handle global items like
loggers and subsystem servers.
> 2. Can I put custom xsl:fo elements in the document and then
> register my own "renderers" for dealing with those types?
The renderers are more oriented toward a given output medium, so you are
more likely going to be modifying or extending one to handle your custom
elements, but yes, this general technique could work as well. My guess is
that this is probably even more of a pain than option 1 above. Some
information is here:
http://xml.apache.org/fop/dev/extensions.html
Victor Mote
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org