1 3 import java.util.*; 4 import java.io.*; 5 import java.awt.Color ; 6 import org.faceless.pdf2.*; 7 8 public class HelloUnicodeWorld 15 { 16 public static void main(String [] args) 17 throws IOException 18 { 19 if (args.length==0) { 20 System.err.println("Usage: java HelloUnicodeWorld <truetype-font-file>\n\nThis program needs a TrueType font containing Arabic and Cyrllic\ncharacters, like \"times.ttf\" (the Times-Roman supplied with\nMicrosoft Windows 2000.\n\n"); 21 System.exit(1); 22 } 23 24 PDF pdf = new PDF(); 26 27 PDFPage page = pdf.newPage(PDF.PAGESIZE_A4); 30 31 PDFStyle mystyle = new PDFStyle(); 35 36 OpenTypeFont otf = new OpenTypeFont(new FileInputStream(args[0]),2); 37 mystyle.setFont(otf, 24); 38 mystyle.setFillColor(Color.black); 39 40 page.setStyle(mystyle); 65 page.drawText("Hello, World\n\u0417\u0434\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u043C\u0438\u0440\n\u010Cau sv\u011bte\n\u0633\u0644\u0627\u0645 \u0627\u0644\u0639\u0627\u0644\u0645\n", 100, page.getHeight()-100); 66 67 pdf.setInfo("Author", "Big Faceless Organization"); 70 pdf.setInfo("Title", "Unicode Text Demonstration"); 71 72 OutputStream fo = new FileOutputStream("HelloUnicodeWorld.pdf"); 75 pdf.render(fo); 76 fo.close(); 77 } 78 } 79 | Popular Tags |