3 Replies Latest reply on May 4, 2010 10:10 AM by mpickell

    Export a rich: DataGrid to PDF

    pablomaes

      Hi,

      I have a problem not solved, I have the  following DataGrid:

       

       

                       <rich:dataGrid
                              value="#{allMatriculasList.resultList}" var="allMatricula"
                              columns="5" elements="60">
                                  <f:facet name="header">
                                          <s:link styleClass="#{allMatriculasList.getOrderStyle('matResProv', 'arrow-down', 'arrow-up', '')}"
                                                   value="#{messages['allMatriculas.matResProv.shortLabel']}" style="color:white;">
                                          <f:param name="allMatriculasOrder" value="#{allMatriculasList.getOrderParam('matResProv')}" />
                                          </s:link>
                                  </f:facet>
                                  <h:panelGrid>                        
                                      <h:outputText
                                          value="#{allMatricula.matResProv}#{allMatricula.matResNum}#{allMatricula.matResLet}" />
                                  </h:panelGrid>
                          </rich:dataGrid>
      
      

       

       

      which represents a table with the following format:

       

      Matriculas

      ---------------

      M1 M2 M3

      M4 M5 M6

      M7 M8 M9

      ...

       

      now I  want to export the same model of representation to PDF, but I can't ..  because with a normal iteration ui: repeat like this:

       

       

      <ui:repeat var="allMatriculas" value="#{allMatriculasList.allResults}" varStatus="aid">
                  <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                      <p:text value="#{allMatriculas.matResProv}&#160;#{allMatriculas.matResNum}&#160;#{allMatriculas.matResLet}&#160;"/>
                      <p:text value="#{aid}&#160;"/>
                  </p:cell>            
      </ui:repeat>
      

       

       

      what I  paint is:

       

      Matriculas
      ---------------
      M1
      M2
      M3
      M4
      M5
      M6
      ...

       

       

       

      I need some help!!

       

      thanks!

        • 1. Re: Export a rich: DataGrid to PDF
          mpickell

          Not sure this is on target, but here are some thoughts:

           

          I am not familiar with the 'p' library you are using -- what are you using for PDF creation (what is the library behind the <p:cell... tag)?  does it have a table element that would allow you to set the number of columns and wrap the <ui:repeat...> so that the table is created correctly?

           

          Have you looked into using something like iText from the bean to create your PDF instead?

          • 2. Re: Export a rich: DataGrid to PDF
            pablomaes

            Thx for your answer..

             

            I'm using Itext pdf library for seam..here is the whole code i'm using for the export:

             

             

            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <p:document xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://jboss.com/products/seam/pdf" pageSize="A4"
                orientation="landscape" type="pdf">
            
                <f:facet name="header">
                    <p:font size="10" style="BOLD">
                        <p:footer borderWidthTop="2" borderColorTop="#C0C0C0" borderWidthBottom="0" alignment="right">
                            <p:pageNumber/>
                        </p:footer>
                    </p:font>
                </f:facet>
            
            
                <p:table columns="8" headerRows="4" widthPercentage="100">
            
                    <p:cell backgroundColor="#FFFFFF" borderWidthLeft="2" borderWidthRight="2"
                     borderColor="#FFFFFF" colspan="11" fixedHeight="50" horizontalAlignment="right">
                         
                    </p:cell>
                    <p:cell backgroundColor="#FFFFFF" borderWidthLeft="2" borderWidthRight="2"
                     borderColor="#FFFFFF" colspan="11" paddingBottom="25">
                         <p:paragraph spacingAfter="25" alignment="center">
                            <p:font size="20">#{branding.getProperty('title')}</p:font>
                        </p:paragraph>
                    </p:cell>
                    <p:cell backgroundColor="#FFFFFF" borderWidthLeft="2" borderWidthRight="2"
                     borderColor="#FFFFFF" colspan="11" paddingBottom="20">
                         <p:paragraph spacingAfter="25" alignment="center">
                             <p:font size="12" style="underline">#{messages['allMatriculas.list']}</p:font>
                         </p:paragraph>
                    </p:cell>
            
                    <f:facet name="defaultCell">
                        <p:cell horizontalAlignment="center" verticalAlignment="middle" borderWidthTop="0" borderWidthBottom="0"
                        borderWidthLeft="0" borderWidthRight="0" paddingBottom="8" paddingTop="-5"/>
                    </f:facet>
            
                    <p:font size="9" fontFamily="Arial" style="bold" color="#FFFFFF">
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['matriculas.matReservada.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.numRegistro.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.fechaAlta.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.fechaBaja.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.matOrdinaria.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.titulares.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.organismos.shortLabel']}"/>
                    </p:cell>
                    <p:cell backgroundColor="#C0C0C0" borderWidthLeft="2" borderWidthRight="2" borderColor="#FFFFFF" paddingTop="1" paddingBottom="5" paddingLeft="5" paddingRight="5">
                        <p:text value="#{messages['allMatriculas.estado.shortLabel']}"/>
                    </p:cell>
                    </p:font>
                    <p:font size="8" fontFamily="Arial Narrow" backgroundColor="#FFFFFF">
                    <ui:repeat var="allMatriculas" value="#{allMatriculasList.allResults}">
            
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.matResProv}&#160;#{allMatriculas.matResNum}&#160;#{allMatriculas.matResLet}&#160;"/>
                        </p:cell>
            
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.numRegistro}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.fechaAlta}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.fechaBaja}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.matOrdinaria}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.titulares.titular}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.organismos.organismo}&#160;"/>
                        </p:cell>
                        <p:cell borderWidthBottom="1" borderColorBottom="#C0C0C0" paddingTop="1" paddingBottom="5"
                                borderWidthRight="2" borderColorRight="#FFFFFF" verticalAlignment="middle" paddingLeft="5" paddingRight="5">
                            <p:text value="#{allMatriculas.estado}&#160;"/>
                        </p:cell>
                    </ui:repeat>
                    </p:font>
                </p:table>
            </p:document>
            

             

            I know i can do what i want throw Itex libray and java code.. but i would like to use seam because i used it in other export cases...

            • 3. Re: Export a rich: DataGrid to PDF
              mpickell

              based on my knowledge of iText, it looks like your table is set up as I would expect.  however, your first couple of cells have colspan=11, and i'm not sure how that would work out in an 8 column table.

               

              have you stripped out everything except the ...ui:repeat... and see if it renders any better?

               

              You also may want to try moving the question to a seam-specific discussion listing.  It doesn't look like the rich:datagrid is actually used in this pdf markup.

               

              Sorry I cannot offer more help.