turkish character not appearing in pDF document(PDFGraphics2D)
===


The following code is simplified case for my Java2D application which prints to PDF. It some how does not print ['Dotted I in turkish language.][1]' using the [PDFGrahics2D][2].


    import com.lowagie.text.pdf.PdfWriter;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfTemplate;
    import com.lowagie.text.pdf.DefaultFontMapper;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.Rectangle;
    
    import java.io.FileOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.awt.Graphics2D;
    import java.awt.Font;
    
    public class DottedIExampleWithGraphics2D
    {
    
    	private static final float WIDTH = 900;
    	private static final float HEIGHT = 500;
    	private DefaultFontMapper mapper = new DefaultFontMapper();
    
    	public void testWriteOfStringWithFont() throws IOException, DocumentException
    	{
    
    		File fontFile = new File("c:/windows/fonts/arialuni.ttf");
    		BaseFont bf = BaseFont.createFont(fontFile.getAbsolutePath(),
    				BaseFont.IDENTITY_H,
    				BaseFont.NOT_EMBEDDED);
    		Font theFont = mapper.pdfToAwt(bf, 18);
    		Document document = new Document(new Rectangle(WIDTH, HEIGHT));
    
    		File testFile = new File("learning_withfont.pdf");
    		FileOutputStream fos = new FileOutputStream(testFile);
    		PdfWriter writer = PdfWriter.getInstance(document, fos);
    		document.open();
    
    		PdfContentByte cb = writer.getDirectContent();
    		PdfTemplate tp = cb.createTemplate(WIDTH, HEIGHT);
    		cb.addTemplate(tp, 0, 0);
    		Graphics2D graphics = tp.createGraphics(WIDTH, HEIGHT, mapper);
    
    		graphics.setFont(theFont);
    		graphics.drawString("ABC dotted i=\u0130 , dotted I =\u0131 ", 25, 50);
    
    		graphics.drawString(bf.getPostscriptFontName(), 25, 100);
    
    		//
    		graphics.dispose();
    		document.close();
    
    		System.out.println("testFile.getAbsolutePath() = " + testFile.getAbsolutePath());
    	}
    
    	/**
    	 */
    	public static void main(String[] args) throws IOException, DocumentException
    	{
    		new DottedIExampleWithGraphics2D().testWriteOfStringWithFont();
    	}
    }


The output is like this.

![Dotted I missing in this ][3]



The problem is how to print such characters to PDFGraphics2D. The java code for creating PDF normally, works. Code is here for completion.



    import com.lowagie.text.Chunk;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.Font;
    import com.lowagie.text.Paragraph;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.pdf.PdfWriter;
    
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    public class DottedIExample
    {
    
    	/**
    	 * Creates a PDF document. write a string and font name
    	 */
    	public void createPdf(String filename) throws IOException, DocumentException
    	{
    
    		Document document = new Document();
    		PdfWriter.getInstance(document, new FileOutputStream(filename));
    
    		document.open();
    		File fontFile = new File("c:/windows/fonts/arialuni.ttf");
    		BaseFont bf = BaseFont.createFont(fontFile.getAbsolutePath(),
    				BaseFont.IDENTITY_H,
    				BaseFont.NOT_EMBEDDED);
    		Font font = new Font(bf, 12);
    		document.add(new Paragraph(bf.getPostscriptFontName(), font));
    		document.add(new Paragraph("ABC dotted i=\u0131 , dotted I =\u0130", font));
    		document.add(Chunk.NEWLINE);
    
    		document.close();
    	}
    
    	/**
    	 */
    	public static void main(String[] args) throws IOException, DocumentException
    	{
    		File result = new File("dottedi.pdf");
    		new DottedIExample().createPdf(result.getAbsolutePath());
    		System.out.println("result at = " + result.getAbsolutePath());
    	}
    }


  [1]: http://en.wikipedia.org/wiki/Dotted_and_dotless_I
  [2]: http://api.itextpdf.com/itext/com/itextpdf/awt/PdfGraphics2D.html
  [3]: http://i.stack.imgur.com/R7rq6.png