On 21.10.2008 00:07:51 gennady wrote:
> 
> Hi,
> Here is the snippet of the code that should print horizontally 1 or 2
> business card-like tables inside each row. But they became left - justified.
> And I need them to be centered. I put text-align="center" numerous times and
> it didn't help. Basically I did not right this code. My job was to add
> images and make them centerd. I added the images successfully, as you see,
> but couldn't center the tables.
> Imagine you have 2 business cards on 1 row:                              
> FOTO  Full Name                  FOTO  Full Name                             
> 40x40  Address                    40x40  Address                              
>           
>           City, ST Zip                        City, ST Zip                    
>                     
>           Telephone                          Telephone                        
>                 
>           Email                                 Email
> Or only 1 card:                                                 
> FOTO   Full Name                                                
> 40x40  Address                                                                
>               
>           City, ST Zip
>           Telephone                                                           
>                             
>           Email                                

Centering one table is described at 
http://xmlgraphics.apache.org/fop/faq.html#fo-center-table-horizon

Centering two tables next to each other (if I understand you correctly)
might be done as shown in the attached FO file.

> Also is there a way to print out generated FOP output after processing
> through the scriptlets code?

Depends. I don't have the full picture to answer that. Using FOP's print
renderer (-print on the command-line) you can print to a local printer
driver. Remote printing a PDF in the client's browser is tricky. You
might want to search the mailing list archive for ideas. Questions like
this have come up before.

HTH

> Thank you,
> 
> -Gennady
> <fo:block text-align="center">
>   <fo:table text-align="center" table-layout="fixed" hyphenate="true"
> language="en" width="100%">
>     <fo:table-column column-width="2cm"/>
>     <fo:table-column column-width="4cm"/>
>     <fo:table-column column-width="proportional-column-width(1)"/>
> 
>     <!--  we will paint three columns if there are more than one agent -->
>     <% if (agentNumber > 1) { %>
>     <fo:table-column column-width="2cm"/>
>     <fo:table-column column-width="4cm"/>
>     <fo:table-column column-width="proportional-column-width(1)"/>
>     
>     <% } %>
> 
>     <fo:table-body>
>       <fo:table-row text-align="center"> <!-- first group of Agent -->
> 
>          <%
>           for (i=0; i < agentNumber; i=i+3)
>           {
>             // for printing the Agent name
>             for (j=i; (j < agentNumber & j<=(i+2)); j++)
>               {
>                 %>
>                 <fo:table-cell text-align="center">
>                     <fo:block>
>                         <fo:external-graphic src="<%=
> arrAgent[j].getThumbImageUrl()%>" width="40px" height="40px"/>
>                       </fo:block>
>                   </fo:table-cell>
>                 <fo:table-cell>
>                   <fo:block margin-left="0pt" padding-left="5pt">
>                   <fo:table width="100%" text-align="left">
>                   <fo:table-column
> column-width="proportional-column-width(1)"/>
>                     <fo:table-body>
>                       <fo:table-row>        
>                         <!-- Agent name -->
>                         <fo:table-cell >
>                           <fo:block font-weight="bold">
>                            <% if (arrAgent[j].getCustomName() != null) {
>                                 if (!"".equalsIgnoreCase(
> arrAgent[j].getCustomName() )) { %>
>                                   <![CDATA[<%=
> arrAgent[j].getCustomName()%>]]>
>                              <% } else { %>
>                                   <![CDATA[<%=
> arrAgent[j].getDisplayName()%>]]>
>                              <% } %>
>                            <% } else { %>
>                                    <![CDATA[<%=
> arrAgent[j].getDisplayName()%>]]>
>                            <% } %>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
>                       <fo:table-row>
>                         <!-- Agent office -->
>                         <fo:table-cell>
>                           <fo:block>
>                             <% if (arrAgent[j].getOfficeVO().getCity() !=
> null) { %>
>                             <![CDATA[<%= arrAgent[j].getOfficeVO().getCity()
> + " Office"%>]]>
>                             <% } %>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
>                       <fo:table-row>
>                         <!-- office address -->
>                         <fo:table-cell>
>                           <fo:block>
>                             <% if (arrAgent[j].getOfficeVO().getAddress() !=
> null) { %>
>                             <![CDATA[<%=
> arrAgent[j].getOfficeVO().getAddress() %>]]>
>                             <% } %>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
>                       <fo:table-row>
>                         <!-- office city, state and zip -->
>                         <fo:table-cell>
>                           <fo:block>
>                             <% if (arrAgent[j].getOfficeVO().getCity()  !=
> null) { %>
>                             <![CDATA[<%= arrAgent[j].getOfficeVO().getCity()
> + ", " %>]]>
>                             <% } %>
>                             <% if (arrAgent[j].getOfficeVO().getState() !=
> null ) { %>
>                             <![CDATA[<%=
> arrAgent[j].getOfficeVO().getState() + " " %>]]>
>                             <% } %>
>                             <% if (arrAgent[j].getOfficeVO().getZip() !=
> null) { %>
>                             <![CDATA[<%= arrAgent[j].getOfficeVO().getZip()
> %>]]>
>                             <% } %>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
>                       <fo:table-row>
>                         <!-- Agent phone -->
>                         <fo:table-cell>
>                           <fo:block>
>                             <% if (arrAgent[j].getPhone() != null) { %>
>                             <![CDATA[<%=
> phoneFormat(arrAgent[j].getOfficeVO().getPhone()) %>]]>
>                             <% } %>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
> 
>                       <% if ( (arrAgent[j].getEmail() != null) ) { %>
>                       <fo:table-row>
>                         <!-- Agent email address -->
>                         <fo:table-cell>
>                           <fo:block font-size="10pt">
>                             <![CDATA[<%= arrAgent[j].getEmail()%>]]>
>                           </fo:block>
>                         </fo:table-cell>
>                       </fo:table-row>
>                       <% }  %>
>                     </fo:table-body>
>                   </fo:table>
>                 </fo:block>
>                </fo:table-cell>
>               
>             <fo:table-cell><fo:block></fo:block></fo:table-cell> <!-- prints
> empty cell -->
>             
>         <% } %>
>           
>         <% } %>
>         </fo:table-row> <!-- end of next group of agents -->
>     </fo:table-body>
>   </fo:table>
>   </fo:block>
> -- 
> View this message in context: 
> http://www.nabble.com/How-to-center-horizontally-1-or-2-tables-within-other-table--tp20079740p20079740.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 



Jeremias Maerki

Attachment: center-two-tables.fo
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to