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 Eric Douglas <ed...@blockhouse.com> on 2010/11/17 17:16:08 UTC

Renderable

I'm creating an object of type
org.apache.fop.render.awt.viewer.PreviewPanel.
The constructor is (FOUserAgent foUserAgent, Renderable renderable,
AWTRenderer renderer).
I'm running a client-server program in webstart.
Of course the PreviewPanel must be created as a client object.
This works if I pass a null for Renderable, but also seems to require
that I tie my AWTRenderer to a client Fop object to do a client
transform.
The transform runs a lot faster on the server.
I was wondering if I can do the transform on the server and just pass
the result into the client.
That appears to be the purpose of the Renderable class.
I don't see any FOP classes which return or implement a Renderable.  How
do I generate one?

RE: Renderable

Posted by Eric Douglas <ed...@blockhouse.com>.
As I tried to break it down to send you an actual code sample so you
could see how the ugly code works, which was doing a transform on the
client, and see what I was trying to do with transforming on the server
which wasn't working, I started to examine each object and each step and
figure out it's purpose.  I ultimately realized that while my attempt at
transforming the document on the server to load in the client
PreviewPanel wasn't getting any errors (or output), it was also missing
some things and had some things which weren't even doing anything.  I've
debugged the disconnect and it works!

My print portion of the program is using the Fop class to connect
everything.  I create the Fop with a ByteArrayOutputStream.  Then I
create a SAXResult object using the Fop getDefaultHandler method.  Then
I pass that SAXResult as the output to the javax transform method and
the Fop class links it back to put a finished document in the
ByteArrayOutputStream.  I get the bytes from that output stream to
generate a ByteArrayInputStream which I pass as input to create a
PDDocument object with the pdfbox project, which I can either save as a
PDF file or pass to the printer using java's PrinterJob.  Since that
output is in byte[] form in between the output stream and the input
stream, I can either create that PDF on the server or copy the bytes
down to create it directly on the client.

Now we get to how that all ties together.  I checked the PreviewPanel
and saw there is no way to pass the finished document.  That document
goes through the Renderer.  I looked at AWTRenderer and saw the document
can be passed in using the Renderable class.  I couldn't figure out how
to connect this to the Fop class which is generating the finished
document in the previously described print portion, then I figured out
this is just a convenience class to connect the transforming to the
rendering.  What I needed in order to use the Renderable class was the
intermediate stage.  I replaced the SAXResult output for the transform
on the server with a StreamResult which can be tied to a file.  This
generated the FO file which is the transformed, unrendered document.
The Java File is serializable, so I just copied that to the client for
input to the cli InputHandler.  Then I execute the InputHandler's
renderTo and pass it to the AWTRenderer's setRenderable, and I have a
finished document for the PreviewPanel.  I still have to create the
FopFactory, the FOUserAgent, and the AWTRenderer on the client, but
leaving the XML, XSL, and the Transformer on the server saves a lot.


-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Friday, November 19, 2010 3:41 AM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Renderable

I think you have two options:

1. Create a bitmap (with PNGDocumentHandler (image/png)) on the server
and send that to the client. But you will likely have to produce your
own viewer and cannot reuse FOP's preview dialog.

2. Generate the IF XML format on the server, send that to the client and
use the org.apache.fop.cli.IFInputHandler to render the IF XML file in
FOP's preview dialog. That at least does the layout part on the server,
but if your document contains SVGs or barcodes, that part will still be
processed on the client-side FOP.

Please note that FOP's Renderable class is not the same as AWT's
Renderable.

And FOP has multiple implementations of it own Renderable interface in
the org.apache.fop.cli package.

If you want to off-load as much as possible to the server, you should
pursue option 1.

On 17.11.2010 17:16:08 Eric Douglas wrote:
> I'm creating an object of type
> org.apache.fop.render.awt.viewer.PreviewPanel.
> The constructor is (FOUserAgent foUserAgent, Renderable renderable, 
> AWTRenderer renderer).
> I'm running a client-server program in webstart.
> Of course the PreviewPanel must be created as a client object.
> This works if I pass a null for Renderable, but also seems to require 
> that I tie my AWTRenderer to a client Fop object to do a client 
> transform.
> The transform runs a lot faster on the server.
> I was wondering if I can do the transform on the server and just pass 
> the result into the client.
> That appears to be the purpose of the Renderable class.
> I don't see any FOP classes which return or implement a Renderable.  
> How do I generate one?




Jeremias Maerki


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


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


Re: Add-ons for Apache FOP

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
If you don't know the sizes of the images at design time, you'd probably
have to write an XSLT plug-in that would pre-load the image using the
image loading framework from Apache XML Graphics Commons. This should be
quite fast at runtime but possibly not so quick to implement.


On 03.12.2010 00:21:53 Lucian Opris wrote:
> Thank you again for the answer. Considering I'll use fo:external-graphic, is
> there easy way to determine page size in style? For large attachments (100
> pages) having many fo:page-sequence will not slow down the rendering
> process?
> Thanks,
> 
> Lucian Opris
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Sent: Thursday, December 02, 2010 2:07 AM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Add-ons for Apache FOP
> 
> fox:external-document doesn't allow any additional content besides the
> full-page images. You'll have to determine the page sizes yourself and
> use normal fo:page-sequence elements to set up the image for full-page
> display.
> 
> The PDF size increases that much because there is currently no easy way
> to cache the already transferred PDF objects so they are not transferred
> again for each page. I've experimented with that some time ago but had
> to disable that feature because of massive problems. I may revisit this
> at some point (no current plans). If you have to add larger PDFs to a
> document I suggest you do that as a post-processing step using Apache
> PDFBox.
> 
> On 01.12.2010 21:45:05 Lucian Opris wrote:
> > Also, I've noticed that without using fox:external-document the pdf size
> is
> > about 17K  then using fox:external-document to call a 608K PDF I've got a
> > resulting 2.104K PDF. Do you know what could cause such a dramatic file
> > increase?
> > 
> > Lucian Opris
> > 
> > -----Original Message-----
> > From: Lucian Opris [mailto:lucian.opris@bluematrix.com] 
> > Sent: Wednesday, December 01, 2010 3:12 PM
> > To: fop-users@xmlgraphics.apache.org
> > Subject: RE: Add-ons for Apache FOP
> > 
> > Thank you Jeremias,
> > I've added the <fox:external-document
> > src="C:/FOP1/fop-1.0/attachments/my.pdf"/> to work in conjunction with new
> > namespace
> > xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" and it worked
> fine.
> > Now the question is can we stamp header and footers on external pdf called
> > with fox since fox:external-document is peer with fo:page-sequence?
> > 
> > 
> > Lucian Opris
> > 
> > -----Original Message-----
> > From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> > Sent: Wednesday, December 01, 2010 2:13 AM
> > To: fop-users@xmlgraphics.apache.org
> > Subject: Re: Add-ons for Apache FOP
> > 
> > Hi Lucian
> > 
> > On 30.11.2010 20:35:48 Lucian Opris wrote:
> > > Hi Jeremias,
> > > I'm using your FOP add-ons to call PDF attachments as images using
> > > <fo:external-graphic src="my-doc.pdf#page=1"/>.
> > > Is there a way to preserve pdf page size for landscape pages or should I
> > use
> > > <fox:external-document src="my-doc.pdf"/>?
> > 
> > Support for landscape pages is available in the latest release (2.0.0)
> > of the plug-in.
> > 
> > > Are PDFs with mixed pagesizes work with <fox:external-document and have
> > the
> > > footer stamping start at the same point from left?
> > 
> > Not sure what you mean by that. With fox:external-document the target
> > page will have the exact size of the respective input page. This should
> > work for each page independently.
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org




Jeremias Maerki


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


RE: Add-ons for Apache FOP

Posted by Lucian Opris <lu...@bluematrix.com>.
Thank you again for the answer. Considering I'll use fo:external-graphic, is
there easy way to determine page size in style? For large attachments (100
pages) having many fo:page-sequence will not slow down the rendering
process?
Thanks,

Lucian Opris

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Thursday, December 02, 2010 2:07 AM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Add-ons for Apache FOP

fox:external-document doesn't allow any additional content besides the
full-page images. You'll have to determine the page sizes yourself and
use normal fo:page-sequence elements to set up the image for full-page
display.

The PDF size increases that much because there is currently no easy way
to cache the already transferred PDF objects so they are not transferred
again for each page. I've experimented with that some time ago but had
to disable that feature because of massive problems. I may revisit this
at some point (no current plans). If you have to add larger PDFs to a
document I suggest you do that as a post-processing step using Apache
PDFBox.

On 01.12.2010 21:45:05 Lucian Opris wrote:
> Also, I've noticed that without using fox:external-document the pdf size
is
> about 17K  then using fox:external-document to call a 608K PDF I've got a
> resulting 2.104K PDF. Do you know what could cause such a dramatic file
> increase?
> 
> Lucian Opris
> 
> -----Original Message-----
> From: Lucian Opris [mailto:lucian.opris@bluematrix.com] 
> Sent: Wednesday, December 01, 2010 3:12 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: RE: Add-ons for Apache FOP
> 
> Thank you Jeremias,
> I've added the <fox:external-document
> src="C:/FOP1/fop-1.0/attachments/my.pdf"/> to work in conjunction with new
> namespace
> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" and it worked
fine.
> Now the question is can we stamp header and footers on external pdf called
> with fox since fox:external-document is peer with fo:page-sequence?
> 
> 
> Lucian Opris
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Sent: Wednesday, December 01, 2010 2:13 AM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Add-ons for Apache FOP
> 
> Hi Lucian
> 
> On 30.11.2010 20:35:48 Lucian Opris wrote:
> > Hi Jeremias,
> > I'm using your FOP add-ons to call PDF attachments as images using
> > <fo:external-graphic src="my-doc.pdf#page=1"/>.
> > Is there a way to preserve pdf page size for landscape pages or should I
> use
> > <fox:external-document src="my-doc.pdf"/>?
> 
> Support for landscape pages is available in the latest release (2.0.0)
> of the plug-in.
> 
> > Are PDFs with mixed pagesizes work with <fox:external-document and have
> the
> > footer stamping start at the same point from left?
> 
> Not sure what you mean by that. With fox:external-document the target
> page will have the exact size of the respective input page. This should
> work for each page independently.



Jeremias Maerki


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




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


Re: Add-ons for Apache FOP

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
fox:external-document doesn't allow any additional content besides the
full-page images. You'll have to determine the page sizes yourself and
use normal fo:page-sequence elements to set up the image for full-page
display.

The PDF size increases that much because there is currently no easy way
to cache the already transferred PDF objects so they are not transferred
again for each page. I've experimented with that some time ago but had
to disable that feature because of massive problems. I may revisit this
at some point (no current plans). If you have to add larger PDFs to a
document I suggest you do that as a post-processing step using Apache
PDFBox.

On 01.12.2010 21:45:05 Lucian Opris wrote:
> Also, I've noticed that without using fox:external-document the pdf size is
> about 17K  then using fox:external-document to call a 608K PDF I've got a
> resulting 2.104K PDF. Do you know what could cause such a dramatic file
> increase?
> 
> Lucian Opris
> 
> -----Original Message-----
> From: Lucian Opris [mailto:lucian.opris@bluematrix.com] 
> Sent: Wednesday, December 01, 2010 3:12 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: RE: Add-ons for Apache FOP
> 
> Thank you Jeremias,
> I've added the <fox:external-document
> src="C:/FOP1/fop-1.0/attachments/my.pdf"/> to work in conjunction with new
> namespace
> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" and it worked fine.
> Now the question is can we stamp header and footers on external pdf called
> with fox since fox:external-document is peer with fo:page-sequence?
> 
> 
> Lucian Opris
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Sent: Wednesday, December 01, 2010 2:13 AM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Add-ons for Apache FOP
> 
> Hi Lucian
> 
> On 30.11.2010 20:35:48 Lucian Opris wrote:
> > Hi Jeremias,
> > I'm using your FOP add-ons to call PDF attachments as images using
> > <fo:external-graphic src="my-doc.pdf#page=1"/>.
> > Is there a way to preserve pdf page size for landscape pages or should I
> use
> > <fox:external-document src="my-doc.pdf"/>?
> 
> Support for landscape pages is available in the latest release (2.0.0)
> of the plug-in.
> 
> > Are PDFs with mixed pagesizes work with <fox:external-document and have
> the
> > footer stamping start at the same point from left?
> 
> Not sure what you mean by that. With fox:external-document the target
> page will have the exact size of the respective input page. This should
> work for each page independently.



Jeremias Maerki


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


RE: Add-ons for Apache FOP

Posted by Lucian Opris <lu...@bluematrix.com>.
Also, I've noticed that without using fox:external-document the pdf size is
about 17K  then using fox:external-document to call a 608K PDF I've got a
resulting 2.104K PDF. Do you know what could cause such a dramatic file
increase?

Lucian Opris

-----Original Message-----
From: Lucian Opris [mailto:lucian.opris@bluematrix.com] 
Sent: Wednesday, December 01, 2010 3:12 PM
To: fop-users@xmlgraphics.apache.org
Subject: RE: Add-ons for Apache FOP

Thank you Jeremias,
I've added the <fox:external-document
src="C:/FOP1/fop-1.0/attachments/my.pdf"/> to work in conjunction with new
namespace
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" and it worked fine.
Now the question is can we stamp header and footers on external pdf called
with fox since fox:external-document is peer with fo:page-sequence?


Lucian Opris

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Wednesday, December 01, 2010 2:13 AM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Add-ons for Apache FOP

Hi Lucian

On 30.11.2010 20:35:48 Lucian Opris wrote:
> Hi Jeremias,
> I'm using your FOP add-ons to call PDF attachments as images using
> <fo:external-graphic src="my-doc.pdf#page=1"/>.
> Is there a way to preserve pdf page size for landscape pages or should I
use
> <fox:external-document src="my-doc.pdf"/>?

Support for landscape pages is available in the latest release (2.0.0)
of the plug-in.

> Are PDFs with mixed pagesizes work with <fox:external-document and have
the
> footer stamping start at the same point from left?

Not sure what you mean by that. With fox:external-document the target
page will have the exact size of the respective input page. This should
work for each page independently.


Jeremias Maerki


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




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




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


RE: Add-ons for Apache FOP

Posted by Lucian Opris <lu...@bluematrix.com>.
Thank you Jeremias,
I've added the <fox:external-document
src="C:/FOP1/fop-1.0/attachments/my.pdf"/> to work in conjunction with new
namespace
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" and it worked fine.
Now the question is can we stamp header and footers on external pdf called
with fox since fox:external-document is peer with fo:page-sequence?


Lucian Opris

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Wednesday, December 01, 2010 2:13 AM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Add-ons for Apache FOP

Hi Lucian

On 30.11.2010 20:35:48 Lucian Opris wrote:
> Hi Jeremias,
> I'm using your FOP add-ons to call PDF attachments as images using
> <fo:external-graphic src="my-doc.pdf#page=1"/>.
> Is there a way to preserve pdf page size for landscape pages or should I
use
> <fox:external-document src="my-doc.pdf"/>?

Support for landscape pages is available in the latest release (2.0.0)
of the plug-in.

> Are PDFs with mixed pagesizes work with <fox:external-document and have
the
> footer stamping start at the same point from left?

Not sure what you mean by that. With fox:external-document the target
page will have the exact size of the respective input page. This should
work for each page independently.


Jeremias Maerki


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




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


Re: Add-ons for Apache FOP

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Lucian

On 30.11.2010 20:35:48 Lucian Opris wrote:
> Hi Jeremias,
> I'm using your FOP add-ons to call PDF attachments as images using
> <fo:external-graphic src="my-doc.pdf#page=1"/>.
> Is there a way to preserve pdf page size for landscape pages or should I use
> <fox:external-document src="my-doc.pdf"/>?

Support for landscape pages is available in the latest release (2.0.0)
of the plug-in.

> Are PDFs with mixed pagesizes work with <fox:external-document and have the
> footer stamping start at the same point from left?

Not sure what you mean by that. With fox:external-document the target
page will have the exact size of the respective input page. This should
work for each page independently.


Jeremias Maerki


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


Add-ons for Apache FOP

Posted by Lucian Opris <lu...@bluematrix.com>.
Hi Jeremias,
I'm using your FOP add-ons to call PDF attachments as images using
<fo:external-graphic src="my-doc.pdf#page=1"/>.
Is there a way to preserve pdf page size for landscape pages or should I use
<fox:external-document src="my-doc.pdf"/>?
Are PDFs with mixed pagesizes work with <fox:external-document and have the
footer stamping start at the same point from left?

Thanks

Lucian Opris



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


Re: Renderable

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I think you have two options:

1. Create a bitmap (with PNGDocumentHandler (image/png)) on the server
and send that to the client. But you will likely have to produce your
own viewer and cannot reuse FOP's preview dialog.

2. Generate the IF XML format on the server, send that to the client and
use the org.apache.fop.cli.IFInputHandler to render the IF XML file in
FOP's preview dialog. That at least does the layout part on the server,
but if your document contains SVGs or barcodes, that part will still be
processed on the client-side FOP.

Please note that FOP's Renderable class is not the same as AWT's
Renderable.

And FOP has multiple implementations of it own Renderable interface in
the org.apache.fop.cli package.

If you want to off-load as much as possible to the server, you should
pursue option 1.

On 17.11.2010 17:16:08 Eric Douglas wrote:
> I'm creating an object of type
> org.apache.fop.render.awt.viewer.PreviewPanel.
> The constructor is (FOUserAgent foUserAgent, Renderable renderable,
> AWTRenderer renderer).
> I'm running a client-server program in webstart.
> Of course the PreviewPanel must be created as a client object.
> This works if I pass a null for Renderable, but also seems to require
> that I tie my AWTRenderer to a client Fop object to do a client
> transform.
> The transform runs a lot faster on the server.
> I was wondering if I can do the transform on the server and just pass
> the result into the client.
> That appears to be the purpose of the Renderable class.
> I don't see any FOP classes which return or implement a Renderable.  How
> do I generate one?




Jeremias Maerki


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