5 Replies Latest reply on Mar 14, 2007 11:19 AM by Petr Ferschmann

    iText PDF generation

    emerson carara Newbie

      Hi,

      I´ve started using iText PDF generation on my project.
      Every thing works fine except for portuguese character set support .

      The problem is some special characters (like "ç" or "~" etc) are being converted to HTML Character Entities (http://www.w3schools.com/tags/ref_entities.asp)

      For example,

      <p:paragraph>ç</p:paragraph>
      


      will be rendered to

      & 231;
      


      I´m using seam version 1.1.6.

      My page
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <p:document xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:p="http://jboss.com/products/seam/pdf" >
       <p:font size="24">
       <p:paragraph spacingAfter="50">
       <p:font familyName="courier">
       Acompanhamento de Processos - Depto. Jurídico
       </p:font>
       </p:paragraph>
       </p:font>
      
      
       <p:table columns="1" >
       <ui:repeat value="#{relprocativos.processos}" var="processo">
       <p:cell>#{processo.numProc}</p:cell>
       </ui:repeat>
       </p:table>
      </p:document>
      


      my components.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:pdf="http://jboss.com/products/seam/pdf"
       xsi:schemaLocation=
       "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
      
       <pdf:documentStore useExtensions="true" errorPage="/pdfMissing.seam" />
      
       <pdf:keyStoreConfig keyStore="pdf.keystore"
       keyStorePassword="storepass"
       keyPassword="keypass"
       keyAlias="pdfKey" />
      
       <core:init jndi-pattern="@jndiPattern@" debug="true"/>
      
       <core:manager conversation-timeout="600000"
       concurrent-request-timeout="500"
       conversation-id-parameter="cid"
       conversation-is-long-running-parameter="clr"/>
      
       <core:transactionListener/>
      
       <core:ejb installed="@embeddedEjb@"/>
      
       <component class="org.jboss.seam.selectitems.SelectItemsConfig">
       <property name="persistenceUnitJndiName">java:/selectItemsEntityManagerFactory</property>
       </component>
      
      
       <component class="org.jboss.seam.jasperreports.JasperReports">
       <property name="reportDefinitions">teste.jrxml</property>
       </component>
      
      
      </components>



      my web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      
      <web-app version="2.5"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      
       <context-param>
       <param-name>javax.faces.CONFIG_FILES</param-name>
       <param-value>/WEB-INF/navigation.xml</param-value>
       </context-param>
      
       <!-- Ajax4jsf (must come first!) -->
      
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
       </context-param>
      
       <!-- Seam -->
      
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <filter>
       <filter-name>Seam Servlet Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Servlet Filter</filter-name>
       <url-pattern>*.pdf</url-pattern>
       </filter-mapping>
      
       <!-- Propagate conversations across redirects -->
       <filter>
       <filter-name>Seam Redirect Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Redirect Filter</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
       <filter>
       <filter-name>Seam Exception Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Exception Filter</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
       <!-- JSF -->
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <!-- Faces Servlet Mapping -->
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
       </servlet-mapping>
      
      
      
      
       <!-- MyFaces -->
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <!-- suporte a pdf -->
       <servlet>
       <servlet-name>Document Store Servlet</servlet-name>
       <servlet-class>org.jboss.seam.pdf.DocumentStoreServlet</servlet-class>
       </servlet>
      
      
       <servlet-mapping>
       <servlet-name>Document Store Servlet</servlet-name>
       <url-pattern>*.pdf</url-pattern>
       </servlet-mapping>
      
      
       <!-- JSF RI -->
       <!--
       <listener>
       <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
       </listener>
       -->
      
       <!-- MyFaces Extensions-->
       <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
       <init-param>
       <param-name>maxFileSize</param-name>
       <param-value>20m</param-value>
       </init-param>
       <init-param>
       <param-name>uploadMaxFileSize</param-name>
       <param-value>100m</param-value>
       <!--
       <description>Set the size limit for uploaded files.
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB
       </description>
       -->
       </init-param>
       <init-param>
       <param-name>uploadThresholdSize</param-name>
       <param-value>100k</param-value>
       <!--
       <description>Set the threshold size - files
       below this limit are stored in memory, files above
       this limit are stored on disk.
      
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB
       </description>
       -->
       </init-param>
       <!--
       <init-param>
       <param-name>uploadRepositoryPath</param-name>
       <param-value>/temp</param-value>
       <description>Set the path where the intermediary files will be stored.
       </description>
       </init-param>
       -->
       </filter>
      
       <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
       <servlet-name>Faces Servlet</servlet-name>
       </filter-mapping>
      
       <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>*.jsf</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>*.jsp</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/*</url-pattern>
       </filter-mapping>
      
       <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>/WEB-INF/tomahawk.taglib.xml;/WEB-INF/mps.taglib.xml</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
       <param-value>false</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
       <param-value>false</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
       <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.jboss.seam.core.init.debug</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- acesso remoto à EJBs via javascript -->
       <servlet>
       <servlet-name>Seam Remoting</servlet-name>
       <servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Seam Remoting</servlet-name>
       <url-pattern>/seam/remoting/*</url-pattern>
       </servlet-mapping>
      
       <session-config>
       <session-timeout>300</session-timeout>
       </session-config>
       </web-app>
      


      tks

      emerson fabiano