-
2. Re: Printable versions of pages
cbensemann Jul 19, 2010 3:24 AM (in response to cbensemann)Thanks Nicklas,
I had found Flying Saucer and it looked promising until I realised the bit about displaying some parts of the page differently whether they are being printed or displayed on screen. For example file upload boxes are useless on paper forms so they shouldn't be rendered at all. Rich:tree would probably best be displayed as a list rather than a tree and I guess picklists would be similar. I dont think this is possible using Flying Saucer alone is it??
Any ideas how I can achieve this?
-
3. Re: Printable versions of pages
serkan.s.eskici.online.nl Jul 20, 2010 5:19 PM (in response to cbensemann)Just use a different css for print and import it with media = print in you html document.
Example
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
This stylesheet is called when someone tries to print your page.
If you want to disable some parts of the page to be printed, just use display: none on those elements.
And use pt instead of px or em for font-size when printing !
If you need more info, google for css & printing, for example this url.
-
4. Re: Printable versions of pages
cbensemann Jul 20, 2010 7:15 PM (in response to cbensemann)Thanks for your reply.
CSS would solve part of the problem. It would let me format the document to fit the correct page size and to hide parts of a form that aren't needed in the print version (such as a file upload component) but CSS will not let me transform the parts of the page. For example a rich:tree or rich:modal panel are interactive components that do things on the screen to allow the user to make selections. printing these out as they appear on screen would not be very helpful to the user filling in the paper form. A person filling in a paper form would need to be presented with a list of options (in the case of a select menu or a rich:tree) and probably have the modal panel printed inline along with the rest of the components on the paper page.
I'm not sure if this next paragraph actually makes my problem clearer or just confuses the issue so if it doesn't make sense you can safely ignore it :)
To complicate matters slightly I have created a collection of custom (dynamic) fields so that the user can configure exactly what fields appear on their form (and these will be different for different companies using my system). This is extremely powerful as it lets the companies taylor our system to suit their needs but means that the forms are not simply
static
xhtml but rather contains a bunch of includes for inserting fields into the template based on the users configuration.I don't think this is a trivial problem as its not just a matter of printing off a
screen shot
or generating a pdf of it but actually generating a usable paper form based on what the user can fill in online.I started looking into the ReplacedElementFactory in flying saucer and it may do what I want but I'm not sure if its the best way to go??
All thoughts and suggestions welcomed.
Craig
-
5. Re: Printable versions of pages
serkan.s.eskici.online.nl Jul 21, 2010 7:38 AM (in response to cbensemann)AFAIK, if you have a dynamic page and press the Print button, then you'll get what you see on your screen.
For printing dropdown boxes with css what you can do is the following:
//your default richfaces dropdown box <rich:dropdown or whatever it's called ../> <ul class="dropdownForPrint"> <ui:repeat value="#{yourItems}" var="item"> <li>#{item.name}</li> </ui:repeat> </ul>
In your default css file:
.dropdownForPrint { display: none }
In your print css file:
.dropdownForPrint { display: block //etc. }
So in other words you'll have to make alternatives or print friendly versions of those components in plain html and only use them in the print.css.
Alternatively, there is another JSF library called PrimeFaces which has a Printer component that can print a specified JSF component on your page.
See it here.
-
6. Re: Printable versions of pages
cbensemann Jul 24, 2010 3:06 AM (in response to cbensemann)Thanks. I'll have another look into this when I get a bit more time.