Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
2 czech Characters getting lost when parsing through IText

2 czech Characters getting lost when parsing through IText

2006-07-22       - By Bela Sharma

 Back
Hi
I get a strange issue with 2 of the czech characters when generating PDF
using IText version 1.4.2.
When customerNumber=Pr??erne ?lutouck? is sent as as input to IText  after
doing following steps
// Step 1: creation of a document-object
document = new Document(PageSize.A4);

// step 2: create a writer that listens to the document
writer = PdfWriter.getInstance(document, baos);
// step 3: we create a parser and set the document handler
                       parser =
SAXParserFactory.newInstance().newSAXParser();
                       InputSource isrc = new InputSource(bais);
                       isrc.setEncoding(getEncodingType());
                       CustomTagHandler cth=   new
CustomTagHandler(document, writer, getCustomMap(),"ISO-8859 (See http://ISO-8859.ora-code.com)-2");

                       // step 4: we parse the document
                       parser.parse(isrc,cth);
                       System.out.println(" in GenericContracttoPdfconv.
parser:"+parser.toString());
                       // step 5: close the document object
                       document.close();

The 2 characters ? and ? are lost and we get boxes in their place.

Here's the constructor for CustomTagHandler

public CustomTagHandler(DocListener _doclistener, PdfWriter
_writer,HashMap hashmap,String encoding_loc)throws DocumentException,
IOException
       {
               super(_doclistener);

               setStrMethodName("CustomTagHandler");  /* NOI18N */
               fillLocaleFont();

               if (encoding_loc.indexOf("-locale-") != -1){
                       position = encoding_loc.indexOf("-locale-");
                       System.out.println("CTH sit_loc:"+encoding_loc+"
pos:"+position);
                       encoding = encoding_loc.substring(0, position);
                       locale = encoding_loc.substring(position+8);
                       System.out.println("CTH enc:"+encoding+" locale:"
+locale);
               }else{
                       encoding = encoding_loc;
                       System.out.println("CTH enco:"+encoding);
               }


               filename=getFontFile(locale);
               setBaseFont(BaseFont.createFont(filename,
encoding,BaseFont.EMBEDDED));
               setMyTags(hashmap);
               setWriter(_writer);
               setDoclistener(_doclistener);
               setCb(_writer.getDirectContent());
               stackThis = new java.util.Stack Source code of java.util.Stack();
               isStackReadyForText = false;
               leftText = null;
               centerText = null;
               rightText = null;


       }

Can you please guide us as to what should we do for those 2 missing
characters.

Regards,
Bela Sharma
IBM India Pvt. Ltd.
India ADC for E-Business Team
Tech Park One (TPO) ,Tower-B
Off Airport Road,Yerwada-Pune
Tel. No. 020-40115523 -ext. 15541
Cell No 9321028514


<br><font size=2 face="sans-serif">Hi</font>
<br><font size=2 face="sans-serif">I get a strange issue with 2 of the
czech characters when generating PDF using IText version 1.4.2.</font>
<br><font size=1 face="Tahoma">When customerNumber=Pr??erne ?lutouck?
is sent as as input to IText &nbsp;after doing following steps</font>
<br><font size=2 color=#3f8080 face="Courier New">// Step 1: creation of
a document-object</font>
<br><font size=2 face="Courier New">document = </font><font size=2 color=
#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
Document(PageSize.A4);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 color=#3f8080 face="Courier New">// step 2: create a writer
that listens to the document</font>
<br><font size=2 face="Courier New">writer = PdfWriter.getInstance(document,
baos);</font>
<br><font size=2 color=#3f8080 face="Courier New">// step 3: we create
a parser and set the document handler</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parser
= SAXParserFactory.newInstance().newSAXParser();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InputSource
isrc = </font><font size=2 color=#820040 face="Courier New"><b>new</b></font>
<font size=2 face="Courier New">
InputSource(bais);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isrc.setEncoding
(getEncodingType());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CustomTagHandler
cth= &nbsp; &nbsp; &nbsp; &nbsp;</font><font size=2 color=#820040 face="Courier
New"><b>new</b></font><font size=2 face="Courier New">
CustomTagHandler(document, writer, getCustomMap(),&quot;ISO-8859 (See http://ISO-8859.ora-code.com)-2&quot;);<
/font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=
#3f8080 face="Courier New">//
step 4: we parse the document</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parser.parse(isrc,cth);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(</font>
<font size=2 color=#4200ff face="Courier New">&quot;
in GenericContracttoPdfconv. parser:&quot;</font><font size=2 face="Courier New
">+parser.toString());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=
#3f8080 face="Courier New">//
step 5: close the document object</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.close();</font>
<br>
<br><font size=2 face="Courier New">The 2 characters </font><font size=1 face=
"Tahoma">?</font><font size=2 face="Courier New">
and </font><font size=1 face="Tahoma">?</font><font size=2 face="Courier New">
are lost and we get boxes in their place.</font>
<br>
<br><font size=2 face="Courier New">Here's the constructor for CustomTagHandler
</font>
<br>
<br><font size=2 color=#820040 face="Courier New"><b>public</b></font><font
size=2 face="Courier New">
CustomTagHandler(DocListener _doclistener, PdfWriter _writer,HashMap hashmap
,String
encoding_loc)</font><font size=2 color=#820040 face="Courier New"><b>throws</b>
</font><font size=2 face="Courier New">
DocumentException, IOException</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b
>super</b></font><font size=2 face="Courier New">(_doclistener);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setStrMethodName(</font><font size=2 color=#4200ff face=
"Courier New">&quot;CustomTagHandler&quot;</font><font size=2 face="Courier New"
>);
&nbsp;</font><font size=2 color=#3f8080 face="Courier New">/* NOI18N */</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; fillLocaleFont();</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>if
</b></font><font size=2 face="Courier New">
(encoding_loc.indexOf(</font><font size=2 color=#4200ff face="Courier New">
&quot;-locale-&quot;</font><font size=2 face="Courier New">)
!= -1){</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position
= encoding_loc.indexOf(</font><font size=2 color=#4200ff face="Courier New">
&quot;-locale-&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(</font>
<font size=2 color=#4200ff face="Courier New">&quot;CTH
sit_loc:&quot;</font><font size=2 face="Courier New">+encoding_loc+</font><font
size=2 color=#4200ff face="Courier New">&quot;
&nbsp;pos:&quot;</font><font size=2 face="Courier New">+position);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding
= encoding_loc.substring(0, position);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; locale
= encoding_loc.substring(position+8);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(</font>
<font size=2 color=#4200ff face="Courier New">&quot;CTH
enc:&quot;</font><font size=2 face="Courier New">+encoding+</font><font size=2
color=#4200ff face="Courier New">&quot;
locale:&quot;</font><font size=2 face="Courier New">+locale);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; }</font><font size=2 color=#820040 face="Courier New"><b
>else</b></font><font size=2 face="Courier New">{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding
= encoding_loc;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(</font>
<font size=2 color=#4200ff face="Courier New">&quot;CTH
enco:&quot;</font><font size=2 face="Courier New">+encoding);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; }</font>
<br>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; filename=getFontFile(locale);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setBaseFont(BaseFont.createFont(filename,
encoding,BaseFont.EMBEDDED)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setMyTags(hashmap);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setWriter(_writer);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setDoclistener(_doclistener);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; setCb(_writer.getDirectContent());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; stackThis = </font><font size=2 color=#820040 face=
"Courier New"><b>new</b></font><font size=2 face="Courier New">
java.util.Stack Source code of java.util.Stack();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; isStackReadyForText = </font><font size=2 color=#820040
face="Courier New"><b>false</b></font><font size=2 face="Courier New">;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; leftText = </font><font size=2 color=#820040 face="Courier
New"><b>null</b></font><font size=2 face="Courier New">;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; centerText = </font><font size=2 color=#820040 face=
"Courier New"><b>null</b></font><font size=2 face="Courier New">;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; rightText = </font><font size=2 color=#820040 face=
"Courier New"><b>null</b></font><font size=2 face="Courier New">;</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="Courier New">Can you please guide us as to what
should we do for those 2 missing characters.</font>
<br>
<br><font size=2 face="sans-serif">Regards,<br>
Bela Sharma<br>
IBM India Pvt. Ltd.<br>
India ADC for E-Business Team<br>
Tech Park One (TPO) ,Tower-B<br>
Off Airport Road,Yerwada-Pune<br>
Tel. No. 020-40115523 -ext. 15541<br>
Cell No 9321028514</font>

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

©2008 junlu.com - Jax Systems, LLC, U.S.A.