Excuse me,

But, Mr. Bruno, IMHO, have you ever tried your code? I also have been tryin
to get Polish characters to display correctly....
Have been puzzling for a week now, asked a Java expert to help, still your
code does NOT display polish characters correctly. I need to stamp a form
with database data over multiple pages, have you got any way of telling the
Stamper to write in a certain code page? You defend your design approach so
fearsly, but I (with me others) find is strange that a document writes out
all existing writers created earlier in a program by document.close() I
thought in java we would code according to standards like MVC, which to my
opinion would lead to some sort of wrapper class instead of a close()
methode... 

Anyway, I believe me we have tried all possible code examples, variants etc.

Perhaps it is the underlying OS that prevents your PdfWriter from writing in
an other codepage other than the operating systems native. If I look at your
source code I did notice a write() methode in DocWriter (PdfWriter extends
DocWriter)... which writes using ansi encoding... ansi is windows-1252 is it
not?
If you would like to put out Polish I believe (sorry, I know..) you should
write in code page windows-1250, Cp1250, ISO-8859-2 or UTF-8....

Please can you explain how and perhaps most important, why it is not
possible to write out a PDF in Polish on an operating system (windows) with
native language of say Dutch or English.

Seriously, I have to get this working and was not able too in a weeks time,
pulling just about all my hair.... for my employer it is way more cheaper to
just go out and buy a package like PDFing or set up a decent apache web
server serving pdf documents... So what's up with the internationalization
and the java code ones run anywhere... 

And yes, I have read most of the book (first edition) and also read your
explaination on design strategy, however your code for producing Polish text
just is NOT working at all at my (and apparently lots of others too...) at
all.

Awaiting your reply!

Greets,

Hans Geerdink
Sorry, you wanted code:
Very simple test program:

import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;

public class testPools
{
        public testPools() //throws UnsupportedEncodingException
        {
                System.out.println("defaultEncodingName = " + 
System.getProperty(
"file.encoding" ));
                System.out.println("user language = " + System.getProperty(
"user.language" ));
                System.out.println("AvailableEncodingName = " +
java.nio.charset.Charset.availableCharsets());
                System.out.println("defaultCharSet = " +
java.nio.charset.Charset.defaultCharset());
                
                //System.setProperty("file.encoding", "UTF-8");
                //System.setProperty("user.language", "pl");
                System.out.println("user language = " + System.getProperty(
"user.language" ));

        }
        public static void main(String[] args) throws Exception
        {
                testPools TP = new testPools();
                
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                
                String outputPDF = "testCCSID.pdf";
                String fontPath  = "./fonts/Polish-European Courier.TTF";
                FileOutputStream fos0 = new FileOutputStream(outputPDF);

                FileOutputStream fos1 = new FileOutputStream(new 
File("pools.pdf"));
                BufferedWriter bufWriter = new BufferedWriter(new
OutputStreamWriter(fos1,"UTF-8"));

                FileOutputStream fos2 = new FileOutputStream(new 
File("pools.txt"));
                BufferedWriter bufWriter1 = new BufferedWriter(new
OutputStreamWriter(fos2,"UTF-8"));

                FileOutputStream fos3 = new FileOutputStream(new 
File("poolsbaos.pdf"));
                BufferedWriter bufWriter2 = new BufferedWriter(new
OutputStreamWriter(fos3,"UTF-8"));

                Document doc = new Document();
                
                //testing bytearrayoutputstream in plaats van 
fileoutputstream...
                PdfWriter writer0 = PdfWriter.getInstance(doc,fos0);
                PdfWriter writer1 = PdfWriter.getInstance(doc,fos1);
                PdfWriter writer2 = PdfWriter.getInstance(doc,baos);
                
                //polish characters in unicode...
                String pstring "Ą Ć Ę Ł Ń Ó Ś Ź Ż ą ć ę ł ń ó ś ź ż, gewoon: a 
b c d e f g
en ik...";
                
                //write buffer to pools.txt file...
                bufWriter1.write(pstring);
                bufWriter1.close();
                
                doc.open();
                
                BaseFont bf = BaseFont.createFont("./fonts/Polish-European
Courier.TTF",BaseFont.CP1250,true);
                Font ft = new Font(bf);
                
                writer0.getDirectContent().setFontAndSize(bf, 10);
                writer1.getDirectContent().setFontAndSize(bf, 10);
                writer2.getDirectContent().setFontAndSize(bf, 10);
                
                doc.add(new Paragraph("Adding a paragraphs in different 
ccsid's, all
polish characters..."));
                
                doc.add(new Paragraph("The default characertset is: " +
System.getProperty("file.encoding")+ '\n'+'\n'));
                doc.add(new Paragraph("pstring, no special encoding:" +'\n'+ 
pstring
+'\n'));
                doc.add(new Paragraph("pstring, special font used:" +'\n'+ 
pstring
+'\n',ft));

                //write to all defined writers...
                doc.close();
                
                //write to mytestfile.pdf...
                FileOutputStream fostest = new 
FileOutputStream("mytestfile.pdf");
                //baos.toString("IBM855");
                baos.writeTo(fostest);
                fostest.close();
                
                System.out.println("Done...");
        }
}


Bruno Lowagie (iText) wrote:
> 
> munesh wrote:
>> It
>> would be of great help if someone can let me know which font and which
>> encoding type i should be using to display the Polish Characters in my
>> PDF
>> reports generated by iText.
> 
> You say Arial doesn't work, but you probably didn't even try. You didn't 
> even bother sending us a sample of what you tried. IMHO you didn't do a 
> lot of effort to read the documentation. Otherwise you'd have written 
> something like this:
> 
> BaseFont bf = BaseFont.createFont("c:/windows/fonts/arial.ttf", 
> BaseFont.CP1250, BaseFont.EMBEDDED);
> Font font = new Font(bf, 12);
> String polish = "\u0104\u0105\u0106\u0107\u0118\u0119";
> document.add(new Paragraph(polish, font));
> 
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Polish-National-Characters-are-not-getting-displayed-in-the-PDF-created-by-iTExt-tp22473150p27106745.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to