FOP provides org.apache.fop.render.awt.viewer.PreviewPanel but it's
ugly. I'm running a client-server program through webstart. My
programs run on the server and of course all GUI objects need to be
created on the client. The PreviewPanel requires a Java transformer and
a Renderer to be created on the client, both of which may take a long
time, at least the first time. They run faster if you run them more
than once so they're cached but my goal is not to create them at all.
So I'm creating my own PreviewPanel with no transformer and no Renderer.
This will display an image, so I require a couple of enhancements. The
first task is creating this new panel object. So I'm looking at FOP's
PreviewPanel to copy some of that logic and I'm confused. What is the
gridPanel object? PreviewPanel extends JPanel but contains an object of
type JPanel? Is it creating a panel within a panel? What's the point
of that? From what I've found my object should need to (extend type or
contain an object of type?) org.jdesktop.swingx.JXPanel to use an
org.jdesktop.swingx.painter.ImagePainter to draw the picture.
My second enhancement I'd like to add would be to do this without
writing any files to disk. For the normal transform I'm generating the
entire output programatically so writing the XML, FO, or PDF files are
all optional. I get the output from Fop in a byte stream which I can
use to either create a Pageable PDF object through pdfbox and send to
the printer without writing to disk or I can clone down to the client to
save as a PDF on their machine. The PNGRenderer only option is to
generate each page as a physical file on disk. I'll want to update this
renderer or write a new one based on it to be able to send the pages to
the byte stream instead, or an array of byte streams one per page.