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 Fred Janon <fj...@gmail.com> on 2007/11/01 14:50:51 UTC

Would an extension to print Gantt charts work?

I just started looking at FOP, therefore I don't really understand what it
can or cannot do. My attention was caught by the different formats that can
be generated. I would like to know if FOP with a custom extension could
generate Gantt charts? I am interested in pdf, PCL and Java/AWT generation.
Is there any documentation about the Java/AWT generation? I don't understand
what FOP would generate for AWT.

Thanks

Fred

Re: Would an extension to print Gantt charts work?

Posted by Abel Braaksma <ab...@xs4all.nl>.
Jeremias Maerki wrote:
> Generally, yes, but (*g*) considering Gantt charts, they could span
> multiple pages, couldn't they? That's where the problem starts.
> fo:instream-foreign-object which is designed to contain foreign XML
> content only generates one viewport/reference pair. So, there's no way
> to split one single Gantt chart between pages. In order to implemet such
> a functionality, you'd have to write your own block-level LayoutManager,
> so FOP is able to break the chart as necessary. That could complicate
> things. Of course, if you can make sure these chart are always single
> images, the approach is like for the Plan or Barcode4J extension.

Just out of interest, but a Gantt chart isn't much more than a couple of 
bars, text, lines etc, isn't it? If you manage to fit it on one page (I 
know, Gantt charts tend to be very wide though), but surely all you need 
is some basic SVG stuff and you don't need to write a complex extension. 
And you can easily wrap it up with some general XSLT stylesheet that 
creates the SVG XML for you based on your Gantt XML data.

However, *if* you write an extension, consider looking up a standard XML 
format for Gantt (if such exists), instead of taking your own format. 
Using a standardized format, however awkward, tends to make it more 
usable for others (that is, if you intend to make your extension 
available to the public).

Googling brought me http://www.ilog.com/products/jviews/gantt/index.cfm, 
which seems to use SDXL, which is "Schedule Data eXchange Language" used 
to build Gantt charts. But from the look of it, I don't believe it is 
open source. But maybe they allow their format to be public which would 
give you a nice start. Then, if you write an extension for FOP, you can 
also use their renderer, they seem to support enough formats, which will 
save you a lot of time (but again, it is not free).

Cheers,
-- Abel Braaksma

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


Re: Would an extension to print Gantt charts work?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 02.11.2007 00:24:32 Fred Janon wrote:
> Thanks Jeremias, thanks Warren! It helps a lot.
> 
> Your two following points made it clearer for me:
> 
> "the answer here is to write your
> Gantt generator to create XSL-FO, which you may then translate into
> something else with FOP"
> 
> "the XSL-FO spec allows foreign XML formats
> and images to be combined with XSL-FO documents"
> 
> I had looked at the Barcode extension code but could not figure out how it
> was involved in the process. A couple of sequence diagrams would have
> helped!

Sure. You can always help us draw these. ;-)

> I will have another look at the Plan extension, it is probably a
> good starting point for understanding extensions more. Thanks also for the
> Java2D/AWT explanation, somehow I was thinking that it would generate some
> AWT components but I guess just generates the content of an AWT component.
> 
> I have a database with task objects with their name, start/end dates,
> completion, etc. I want to compose (to print it via pdf, PCL) a large
> document (10+ pages) containing a Gantt chart composed of a table with rows
> of text and numbers, bars (graphics), columns with dates, a legend and some
> notes, in a very similar way as Microsoft Project. FOP would help me
> formatting the document (margin, centering...) and with the pagination after
> I compose an XML document that describes the content of the document but not
> the pagination?

Generally, yes, but see below.

> FOP could generate the pdf document for example with 10
> pages and the page number with my content segmented on each page?

Generally, yes, but see below.

> Would I
> have to create an extension to draw the graphics for the task bars?

Generally, yes, but (*g*) considering Gantt charts, they could span
multiple pages, couldn't they? That's where the problem starts.
fo:instream-foreign-object which is designed to contain foreign XML
content only generates one viewport/reference pair. So, there's no way
to split one single Gantt chart between pages. In order to implemet such
a functionality, you'd have to write your own block-level LayoutManager,
so FOP is able to break the chart as necessary. That could complicate
things. Of course, if you can make sure these chart are always single
images, the approach is like for the Plan or Barcode4J extension.

> Sorry about all these basic questions, but I have the feeling that FOP can
> save us a lot of time in our project but it's always difficult to figure out
> the use and limits of a technology without spending quite some time on it
> and I don't have much of that.
> 
> Thanks for your help again.
> 
> Fred
<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: Would an extension to print Gantt charts work?

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Nov 2, 2007, at 00:24, Fred Janon wrote:

<snip />
> I have a database with task objects with their name, start/end  
> dates, completion, etc. I want to compose (to print it via pdf,  
> PCL) a large document (10+ pages) containing a Gantt chart composed  
> of a table with rows of text and numbers, bars (graphics), columns  
> with dates, a legend and some notes, in a very similar way as  
> Microsoft Project. FOP would help me formatting the document  
> (margin, centering...) and with the pagination after I compose an  
> XML document that describes the content of the document but not the  
> pagination? FOP could generate the pdf document for example with 10  
> pages and the page number with my content segmented on each page?  
> Would I have to create an extension to draw the graphics for the  
> task bars?
>
> Sorry about all these basic questions, but I have the feeling that  
> FOP can save us a lot of time in our project but it's always  
> difficult to figure out the use and limits of a technology without  
> spending quite some time on it and I don't have much of that.

What you could also do, instead of going the extension path  
completely, is to try and translate the Gantt-chart into a native XSL- 
FO table. First column contains the task name, the others represent  
the plot-range. Either make it a table with a very high-number of  
columns (native FO), or only two: one for the task-name, the second  
to contain the Gantt-bar for each task (the Gantt-bar could still be  
generated by an fo:instream-foreign-object).


Just my 2 cents


Cheers

Andreas

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


Re: Would an extension to print Gantt charts work?

Posted by Fred Janon <fj...@gmail.com>.
Thanks Jeremias, thanks Warren! It helps a lot.

Your two following points made it clearer for me:

"the answer here is to write your
Gantt generator to create XSL-FO, which you may then translate into
something else with FOP"

"the XSL-FO spec allows foreign XML formats
and images to be combined with XSL-FO documents"

I had looked at the Barcode extension code but could not figure out how it
was involved in the process. A couple of sequence diagrams would have
helped! I will have another look at the Plan extension, it is probably a
good starting point for understanding extensions more. Thanks also for the
Java2D/AWT explanation, somehow I was thinking that it would generate some
AWT components but I guess just generates the content of an AWT component.

I have a database with task objects with their name, start/end dates,
completion, etc. I want to compose (to print it via pdf, PCL) a large
document (10+ pages) containing a Gantt chart composed of a table with rows
of text and numbers, bars (graphics), columns with dates, a legend and some
notes, in a very similar way as Microsoft Project. FOP would help me
formatting the document (margin, centering...) and with the pagination after
I compose an XML document that describes the content of the document but not
the pagination? FOP could generate the pdf document for example with 10
pages and the page number with my content segmented on each page? Would I
have to create an extension to draw the graphics for the task bars?

Sorry about all these basic questions, but I have the feeling that FOP can
save us a lot of time in our project but it's always difficult to figure out
the use and limits of a technology without spending quite some time on it
and I don't have much of that.

Thanks for your help again.

Fred

On 11/1/07, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
>
> Apache FOP is primarily an implementation of the XSL-FO standard, so it
> converts XSL-FO to some output format (PDF, PS, PCL etc.). These are the
> basics.
>
> Now, through the standard formatting objects fo:external-graphic and
> fo:instream-foreign-object, the XSL-FO spec allows foreign XML formats
> and images to be combined with XSL-FO documents. For example, FOP has a
> plug-in which lets you use SVG inside XSL-FO. The SVG is interpreted by
> Apache Batik and converted to a suitable target format for a renderer
> (an output format implementation).
>
> An example of an external extension for Apache FOP is Barcode4J, a
> barcode generator. Barcode4J can itself create various output formats:
> SVG, Java2D/AWT, EPS and bitmaps. The FOP plug-in selects the optimal
> output format depending on the renderer in use. For PostScript output,
> the plug-in renders the barcodes to Encapsulated PostScript (EPS). For
> PDF output, it paints the barcode to a Graphics2D instance which happens
> to have a PDF backend.
>
> On Java2D/AWT generation:
> FOP contains a Java2DRenderer which paints the internal representation
> of the processed XSL-FO document (the area tree) using a Graphics2D
> instance. Graphics2D is the main interface of the Java2D infrastructure.
> With this Java2DRenderer, we can do all sorts of things: We can subclass
> it and create bitmaps (PNGRenderer, TIFFRenderer). In that case the
> Graphics2D has a BufferedImage in the back. Finally, the BufferedImage
> is encoded as a PNG or TIFF file. Another subclass of Java2DRenderer is
> the AWTRenderer which ultimately has a AWT/Swing panel in the back. So
> this is used to display a FO document in a GUI application. We can also
> print to a printer this way.
>
> If you now want to create an extension for Gantt charts, the recommended
> approach is as follows:
> - Get or write a library which can produce Gantt charts from XML. You
> need to have the Gantt data as XML in order to embed it in the XSL-FO
> document.
> - Make sure you can produce either SVG or a bitmap from the Gantt data
> using that library. More universal would be to have the library paint
> the Gantt chart using Java2D (Graphics2D).
> - Put the whole thing in a FOP extension.
>
> There's no formal documentation about writing such extensions, yet. But
> there are a few examples where you can start from:
> - The simplest example is the Plan extension which you can find in FOP's
> examples/plan directory. The Plan extension creates an SVG document from
> some custom XML and passes it to FOP.
> - The old MathML extension in FOP's examples/mathml directory.
> - More serious examples can be found in Barcode4J (barcodes) and JEuclid
> (MathML). Barcode4J is probably to most comprehensive and most flexible
> example, but it therefore has its complexity.
>
> HTH,
> Jeremias Maerki
>
>
>
> On 01.11.2007 14:50:51 Fred Janon wrote:
> > I just started looking at FOP, therefore I don't really understand what
> it
> > can or cannot do. My attention was caught by the different formats that
> can
> > be generated. I would like to know if FOP with a custom extension could
> > generate Gantt charts? I am interested in pdf, PCL and Java/AWT
> generation.
> > Is there any documentation about the Java/AWT generation? I don't
> understand
> > what FOP would generate for AWT.
> >
> > Thanks
> >
> > Fred
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>

Re: Would an extension to print Gantt charts work?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Apache FOP is primarily an implementation of the XSL-FO standard, so it
converts XSL-FO to some output format (PDF, PS, PCL etc.). These are the
basics.

Now, through the standard formatting objects fo:external-graphic and
fo:instream-foreign-object, the XSL-FO spec allows foreign XML formats
and images to be combined with XSL-FO documents. For example, FOP has a
plug-in which lets you use SVG inside XSL-FO. The SVG is interpreted by
Apache Batik and converted to a suitable target format for a renderer
(an output format implementation).

An example of an external extension for Apache FOP is Barcode4J, a
barcode generator. Barcode4J can itself create various output formats:
SVG, Java2D/AWT, EPS and bitmaps. The FOP plug-in selects the optimal
output format depending on the renderer in use. For PostScript output,
the plug-in renders the barcodes to Encapsulated PostScript (EPS). For
PDF output, it paints the barcode to a Graphics2D instance which happens
to have a PDF backend.

On Java2D/AWT generation:
FOP contains a Java2DRenderer which paints the internal representation
of the processed XSL-FO document (the area tree) using a Graphics2D
instance. Graphics2D is the main interface of the Java2D infrastructure.
With this Java2DRenderer, we can do all sorts of things: We can subclass
it and create bitmaps (PNGRenderer, TIFFRenderer). In that case the
Graphics2D has a BufferedImage in the back. Finally, the BufferedImage
is encoded as a PNG or TIFF file. Another subclass of Java2DRenderer is
the AWTRenderer which ultimately has a AWT/Swing panel in the back. So
this is used to display a FO document in a GUI application. We can also
print to a printer this way.

If you now want to create an extension for Gantt charts, the recommended
approach is as follows:
- Get or write a library which can produce Gantt charts from XML. You
need to have the Gantt data as XML in order to embed it in the XSL-FO
document.
- Make sure you can produce either SVG or a bitmap from the Gantt data
using that library. More universal would be to have the library paint
the Gantt chart using Java2D (Graphics2D).
- Put the whole thing in a FOP extension.

There's no formal documentation about writing such extensions, yet. But
there are a few examples where you can start from:
- The simplest example is the Plan extension which you can find in FOP's
examples/plan directory. The Plan extension creates an SVG document from
some custom XML and passes it to FOP.
- The old MathML extension in FOP's examples/mathml directory.
- More serious examples can be found in Barcode4J (barcodes) and JEuclid
(MathML). Barcode4J is probably to most comprehensive and most flexible
example, but it therefore has its complexity.

HTH,
Jeremias Maerki



On 01.11.2007 14:50:51 Fred Janon wrote:
> I just started looking at FOP, therefore I don't really understand what it
> can or cannot do. My attention was caught by the different formats that can
> be generated. I would like to know if FOP with a custom extension could
> generate Gantt charts? I am interested in pdf, PCL and Java/AWT generation.
> Is there any documentation about the Java/AWT generation? I don't understand
> what FOP would generate for AWT.
> 
> Thanks
> 
> Fred


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


Re: Would an extension to print Gantt charts work?

Posted by Warren Young <wa...@etr-usa.com>.
Fred Janon wrote:
> I just started looking at FOP, therefore I don't really understand what 
> it can or cannot do. 

Think of FOP as an abstraction on top of other page description 
languages like Postscript or TeX.  It exists because it's more 
convenient to perform automatic manipulations on the pages in XSL-FO 
format than in these more programmer-oriented languages.  It also makes 
multiple output formats from a single source format possible.

> I would like to know if FOP with a custom 
> extension could generate Gantt charts? 

I'm sure there are many people who would find such a generator useful, 
but it's not something that belongs in FOP itself.  FOP is not concerned 
with any particular data, or message.  This is just like asking whether 
Firefox should have a Gantt extension.  Where the answer there would be 
to generate HTML and PNGs and such, the answer here is to write your 
Gantt generator to create XSL-FO, which you may then translate into 
something else with FOP or any other XSL-FO processor that you later 
come to use.

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