Subject: Sun 's Monospaced font does not work properly with AsianFontMapper 2007-10-11 - By ask for
Back 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(); } }
Please find the attached code, the "HWHW" does not properly render ! <br>Thanks.<br><br><br>import java.awt.Graphics2D; <br>import java.io .FileOutputStream; <br>import java.io.IOException; <br> <br>import com .lowagie.text.Document ; <br>import com.lowagie.text.DocumentException; <br>import com.lowagie.text .Rectangle; <br>import com.lowagie.text.pdf.DefaultFontMapper; <br>import com .lowagie.text.pdf.PdfContentByte; <br>import com.lowagie.text.pdf.PdfTemplate ; <br>import com.lowagie.text.pdf.PdfWriter; <br> <br> <br>public class Text { <br> public static void main(String[] args) { <br> Document document = new Document(new Rectangle(150, 150)) ; <br> try { <br> PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream("text.pdf")); <br> document.open(); <br> PdfContentByte cb = writer.getDirectContent(); <br> PdfTemplate tp = cb.createTemplate( 150, 150); <br> DefaultFontMapper mapper = new com .lowagie.text.pdf.AsianFontMapper( <br> com.lowagie.text.pdf.AsianFontMapper.ChineseTraditionalFont _MSung, <br> com.lowagie .text.pdf.AsianFontMapper.ChineseTraditionalEncoding_H ); <br> Graphics2D g2 = tp.createGraphics( 150, 150, mapper); <br> java.awt.Font thisFont = new java.awt.Font("Monospaced", java.awt.Font.PLAIN, 18); <br> g2.setFont(thisFont); <br> g2.drawString ( "HWHW", 0, 20); <br> g2 .drawString("\u6A19\u6977\u9AD4", 0, 50); <br>   ; g2.dispose(); <br> cb .addTemplate(tp, 0, 0); <br> } catch (DocumentException de) { <br> System.err.println (de.getMessage()); <br> } catch (IOException ioe) { <br>  ; System.err.println(ioe.getMessage()); <br>  ; } <br> document.close(); <br> } <br>} <br><br>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|