Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] cp1251 problem in acrobat reader 5.0

serkan koca

2005-08-13


 
    Hi,
 
I have a problem about displaying of cyrilic chars at Acrobat reader 5.0
I am trying to write a unicode char which is '\u0434' with font COURIER and encoding is CP1251 it successfully is created the
pdf file but when I open this file with Acrobat Reader 5.0 there is space char instread of '\u0434' in Acrobat Reader 7.0 I can
see the correct character. My OS is win2000.
 
There is a solution if I embed the font to generated file I can also see the correct char in 5.0 but this time size of the file
increasing.

Is there any solution for this problem?

Below you can  analyze  m sample code.
 
Thanks

 

public static void main(String[] args) {

Document document = null;

try {

char s ='\u0434';

System.out.println("Encodings");

// step 1: creation of a document-object

document = new Document();

// step 2: creation of the writer

//PdfWriter.getInstance(document, new FileOutputStream("/usr/IBMHttpServer/htdocs/fontencoding.pdf"));

PdfWriter.getInstance(document, new FileOutputStream("C:\\fontencoding.pdf"));

// step 3: we open the document

document.open();

// step 4: we add content to the document

//BaseFont courier = BaseFont.createFont("/usr/lpp/X11/lib/X11/fonts/COUR.TTF", "CP1251", false);

BaseFont courier = BaseFont.createFont("c:\\winnt\\fonts\\COUR.TTF", "CP1251",false);

String[] codePages = courier.getCodePagesSupported();

System.out.println("All available encodings:");

for (int i = 0; i < codePages.length; i++) {

System.out.println(codePages[i]);

}

String names[][] = courier.getFullFontName();

System.out.println("\nListing the full font name:\n");

for (int k = 0; k < names.length; ++k) {

for (int i = 0; i < names[k].length; i++) {

System.out.print(names[k][i] + " ");

}

System.out.println();

}

if(courier.charExists(s))

System.out.println("Char bu fontda mevcut");

else

System.out.println("nasıl yani");

Font font = new Font(courier, 12, Font.NORMAL);

Chunk chunk = new Chunk("<a\u0434a>", font);

document.add(chunk);

}

catch(DocumentException de) {

System.err.println(de.getMessage());

}

catch(IOException ioe) {

System.err.println(ioe.getMessage());

} catch (Exception e){

e.printStackTrace();

} finally{

// step 5: we close the document

document.close();

}

}

 





Bu e-posta'nin içerdigi bilgiler (ekleri dahil olmak üzere) gizlidir. Onayimiz olmaksizin üçüncü kisilere açiklanamaz. Bu mesajin gönderilmek istendigi kisi degilseniz, lütfen mesaji sisteminizden derhal siliniz. Finansbank A.S. bu mesajin içerdigi bilgilerin dogrulugu veya eksiksiz oldugu konusunda bir garanti vermemektedir. Bu nedenle bilgilerin ne sekilde olursa olsun içeriginden, iletilmesinden, alinmasindan, saklanmasindan sorumlu degildir. Bu mesajin içerigi yazarina ait olup, Finansbank A.S.'nin görüslerini içermeyebilir.

The information contained in this e-mail (including any attachments) is confidential. It must not be disclosed to any person without our authority. If you are not the intended recipient, please delete it from your system immediately. Finansbank A.S. makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission, reception, storage or use of such in any way whatsoever. Any opinions expressed in this message are those of the author and may not necessarily reflect the opinions of Finansbank A.S.

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