Hi all,I'm using a quite old version of itext (itext-2.0.6.jar) in eclipse 3.4.2 under windows vista. The jvm i'm using is the 1.6.0_12
i'm trying to write an unicode symbol in a pdf pfile: the rightarrow that is \u2192 (i even tried the \u21a6 code)
i wrote some simple code (see the end of this message) and what i got is:the System.ouput says true so i assume that the font i'm building contains the symbol i wanted. But the pdf file contains only the interrogation point (see the small attached file) instead of the right arrow i was expected
As i though that it could come from the old package i was using, i code the same thing with the latest itext version (that is iText-5.0.6.jar) and get the same result.
so, i obviously miss a point but i don't see which one. I also failed to get any usefull clue with google.
Any help would be greatly appreciated. Thank you Yannic package test; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import com.itextpdf.text.Chunk; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Font; import com.itextpdf.text.PageSize; import com.itextpdf.text.Phrase; import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; public class UnicodeOouput { public static void main(String[] inA) { File f = new File("test_unicode_arrow.pdf"); int colCount = 3; PdfPTable datatable = new PdfPTable(colCount);Document document = new Document(PageSize.A4.rotate(), 2, 2, 20, 10);
try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f)); document.open(); for (int i = 0; i < colCount; i++) datatable.addCell("Col" + i); try {BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLDOBLIQUE,
BaseFont.CP1250, true); Font font = new Font(bf); System.out.println(bf.charExists('\u2192')); Phrase p = new Phrase("\u2192", font); datatable.addCell(new PdfPCell(p)); System.out.println(bf.charExists('\u21A6')); p = new Phrase("\u21A6", font); datatable.addCell(new PdfPCell(p)); Chunk c = new Chunk('\u2192', font); p = new Phrase(c); datatable.addCell(new PdfPCell(p)); } catch (IOException e) { e.printStackTrace(); } document.add(datatable); document.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } }
test_unicode_arrow.pdf
Description: Adobe PDF document
------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php