Please find the attached code, the "HWHW" does not properly render !
Thanks.


import java.awt.Graphics2D;
import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.DefaultFontMapper;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;


public class Text {
    public static void main(String[] args) {
    Document document = new Document(new Rectangle(150, 150));
    try {
        PdfWriter writer = PdfWriter.getInstance( document, new
FileOutputStream("text.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate tp = cb.createTemplate( 150, 150);
        DefaultFontMapper mapper = new com.lowagie.text.pdf.AsianFontMapper(

           com.lowagie.text.pdf.AsianFontMapper.ChineseTraditionalFont_MSung,

           com.lowagie.text.pdf.AsianFontMapper.ChineseTraditionalEncoding_H);

        Graphics2D g2 = tp.createGraphics( 150, 150, mapper);
        java.awt.Font thisFont = new java.awt.Font("Monospaced",
java.awt.Font.PLAIN, 18);
        g2.setFont(thisFont);
        g2.drawString( "HWHW", 0, 20);
        g2.drawString("\u6A19\u6977\u9AD4", 0, 50);
        g2.dispose();
        cb.addTemplate(tp, 0, 0);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
    }
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to